|
@@ -20,63 +20,46 @@ class bundling
|
|
|
private $bundling_list;
|
|
|
private $bundling_goods;
|
|
|
private $goods_ids;
|
|
|
-
|
|
|
- private $cur_version = 0;
|
|
|
+ private $verchecker;
|
|
|
|
|
|
private function __construct()
|
|
|
{
|
|
|
-
|
|
|
+ $this->verchecker = new version_checker('activity_version_bundling');
|
|
|
}
|
|
|
static public function instance()
|
|
|
{
|
|
|
if(self::$stInstance == null) {
|
|
|
self::$stInstance = new bundling();
|
|
|
}
|
|
|
- self::$stInstance->init();
|
|
|
+ if(self::$stInstance->verchecker->need_init()) {
|
|
|
+ self::$stInstance->init();
|
|
|
+ }
|
|
|
|
|
|
return self::$stInstance;
|
|
|
}
|
|
|
|
|
|
private function init()
|
|
|
{
|
|
|
- $need_reset = false;
|
|
|
- $version = rkcache('activity_version_bundling');
|
|
|
- if(empty($version)) {
|
|
|
- $this->cur_version = 1;
|
|
|
- wkcache("activity_version_bundling", $this->cur_version);
|
|
|
- $need_reset = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- $version = intval($version);
|
|
|
- if($version > $this->cur_version) {
|
|
|
- $need_reset = true;
|
|
|
- $this->cur_version = $version;
|
|
|
- }
|
|
|
- }
|
|
|
- if($need_reset)
|
|
|
+ $mod = Model('p_bundling');
|
|
|
+ $condition = array();
|
|
|
+ $condition['store_id'] = self::STORE_ID;
|
|
|
+ $condition['state'] = self::STATE_OPEN;
|
|
|
+
|
|
|
+ $this->bundling_list = array();
|
|
|
+ $this->bundling_goods = array();
|
|
|
+ $this->goods_ids = array();
|
|
|
+
|
|
|
+ $list = $mod->getBundlingList(array('bl_state' => self::STATE_OPEN));
|
|
|
+ foreach ($list as $val)
|
|
|
{
|
|
|
- $mod = Model('p_bundling');
|
|
|
- $condition = array();
|
|
|
- $condition['store_id'] = self::STORE_ID;
|
|
|
- $condition['state'] = self::STATE_OPEN;
|
|
|
-
|
|
|
- $this->bundling_list = array();
|
|
|
- $this->bundling_goods = array();
|
|
|
- $this->goods_ids = array();
|
|
|
-
|
|
|
- $list = $mod->getBundlingList(array('bl_state' => self::STATE_OPEN));
|
|
|
- foreach ($list as $val)
|
|
|
- {
|
|
|
- $bl_id = intval($val['bl_id']);
|
|
|
- $this->bundling_list[$bl_id] = $val;
|
|
|
- $this->bundling_goods[$bl_id] = array();
|
|
|
- $bgoods = $mod->getBundlingGoodsList(array('bl_id' => $bl_id, 'bl_appoint' => 1), 'goods_id,bl_goods_price');
|
|
|
- foreach ($bgoods as $goods) {
|
|
|
- $goods_id =intval($goods['goods_id']);
|
|
|
- array_push($this->bundling_goods[$bl_id],$goods);
|
|
|
- $this->goods_ids[$goods_id][] = $bl_id;
|
|
|
- }
|
|
|
+ $bl_id = intval($val['bl_id']);
|
|
|
+ $this->bundling_list[$bl_id] = $val;
|
|
|
+ $this->bundling_goods[$bl_id] = array();
|
|
|
+ $bgoods = $mod->getBundlingGoodsList(array('bl_id' => $bl_id, 'bl_appoint' => 1), 'goods_id,bl_goods_price');
|
|
|
+ foreach ($bgoods as $goods) {
|
|
|
+ $goods_id =intval($goods['goods_id']);
|
|
|
+ array_push($this->bundling_goods[$bl_id],$goods);
|
|
|
+ $this->goods_ids[$goods_id][] = $bl_id;
|
|
|
}
|
|
|
}
|
|
|
}
|