Browse Source

Merge branch 'bonus_manager' of 121.43.114.153:/home/git/repositories/shopnc into bonus_manager

james 8 years ago
parent
commit
aebf0ee6cc

+ 5 - 0
helper/account_helper.php

@@ -13,6 +13,8 @@ require_once (BASE_ROOT_PATH . '/helper/push_helper.php');
 require_once (BASE_ROOT_PATH . '/helper/sms_helper.php');
 require_once (BASE_ROOT_PATH . '/helper/bonus/parameters.php');
 require_once (BASE_ROOT_PATH . '/helper/user_session/favorite.php');
+require_once (BASE_ROOT_PATH . '/helper/user_session/anotice.php');
+
 
 class account_helper
 {
@@ -388,6 +390,9 @@ class account_helper
         $update_info['member_old_login_ip'] = $member_info['member_login_ip'];
 
         Model('member')->editMember(array('member_id' => $member_id), $update_info);
+
+        $anotice  = new user_session\anotice();
+        $anotice->onStatus();
     }
 
     public static function onLogin($member_id)

+ 3 - 1
helper/goods_helper.php

@@ -12,6 +12,7 @@ require_once (BASE_ROOT_PATH . '/helper/goods/commonid_helper.php');
 require_once (BASE_ROOT_PATH . '/helper/predeposit_helper.php');
 require_once (BASE_ROOT_PATH . '/helper/brand_helper.php');
 require_once (BASE_ROOT_PATH . '/helper/user_session/favorite.php');
+require_once (BASE_ROOT_PATH . '/helper/user_session/anotice.php');
 
 class goods_helper
 {
@@ -132,10 +133,11 @@ class goods_helper
         $sort_summarys = [];
 
         $favorate = new user_session\favorite();
+        $anotice  = new user_session\anotice();
         foreach ($goods_list as $goods)
         {
             $summary = new goods_summary($goods);
-            $info = $summary->format($act_type,$act_id,$favorate);
+            $info = $summary->format($act_type,$act_id,$favorate,$anotice);
             $goods_id = intval($goods['goods_id']);
             $sort_summarys[$goods_id] = $info;
 

+ 3 - 2
helper/model/goods_summary.php

@@ -77,7 +77,7 @@ class goods_summary
         return ($add_time > $start || $edit_time > $start);
     }
 
-    public function format(&$act_type, &$act_id,user_session\favorite $favorate)
+    public function format(&$act_type, &$act_id,user_session\favorite $favorate,user_session\anotice $anotice)
     {
         $summary = [];
 
@@ -168,7 +168,8 @@ class goods_summary
             $summary['gap_desc'] = "";
         }
         $summary['earn_bonus'] = $config['bonus_gap']['earn_bonus'];
-        $summary['favored'] = $favorate->favored_goods($this->goods_id);
+        $summary['favored']  = $favorate->favored_goods($this->goods_id);
+        $summary['anoticed'] = $anotice->noticed($this->goods_id);
 
         return $summary;
     }

+ 87 - 0
helper/user_session/anotice.php

@@ -0,0 +1,87 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: stanley-king
+ * Date: 2017/4/6
+ * Time: 上午10:50
+ */
+
+namespace user_session;
+
+require_once (BASE_ROOT_PATH . '/helper/algorithm.php');
+require_once (BASE_ROOT_PATH . '/helper/session_helper.php');
+
+use algorithm;
+use session_helper;
+
+
+class anotice
+{
+    private $mGoods;
+    private $mDirty;
+
+    public function __construct()
+    {
+        $this->mGoods = [];
+        $this->mDirty = false;
+
+        if(isset($_SESSION['arrival_notice'])) {
+            $this->mGoods = $_SESSION['arrival_notice'];
+        }
+    }
+    public function __destruct()
+    {
+        if($this->mDirty) {
+            $_SESSION['arrival_notice'] = $this->mGoods;
+        }
+        $this->mDirty = false;
+    }
+
+    public function onStatus()
+    {
+        $this->mGoods = [];
+        $this->mDirty = true;
+
+        $mod_anotice = Model('arrival_notice');
+        $notices = $mod_anotice->getArrivalNoticeList(array('member_id' => $_SESSION['member_id']));
+
+        foreach ($notices as $item)
+        {
+            $goods_id = intval($item['goods_id']);
+            if($goods_id > 0) {
+                $this->mGoods[] = $goods_id;
+            }
+        }
+        sort($this->mGoods);
+    }
+
+    public function add($goods_id)
+    {
+        $goods_id = intval($goods_id);
+
+        if(algorithm::binary_search($this->mGoods,$goods_id) == false) {
+            $pos = algorithm::lower_bonud($this->mGoods,$goods_id);
+            algorithm::array_insert($this->mGoods,$pos,$goods_id);
+            $this->mDirty  = true;
+        }
+    }
+
+    public function del($goods_id)
+    {
+        $goods_id = intval($goods_id);
+
+        if(algorithm::binary_search($this->mGoods,$goods_id) == true) {
+            $pos = algorithm::lower_bonud($this->mGoods,$goods_id);
+            algorithm::array_erase($this->mGoods,$pos);
+            $this->mDirty  = true;
+        }
+    }
+
+    public function noticed($goods_id)
+    {
+        if(!session_helper::logined()) return false;
+
+        $goods_id = intval($goods_id);
+        return algorithm::binary_search($this->mGoods,$goods_id);
+    }
+}

+ 1 - 1
helper/user_session/favorite.php

@@ -105,7 +105,7 @@ class favorite
         }
         elseif($type == 'goods')
         {
-            if(algorithm::binary_search($this->mGoods,$id) == false) {
+            if(algorithm::binary_search($this->mGoods,$id) == true) {
                 $pos = algorithm::lower_bonud($this->mGoods,$id);
                 algorithm::array_erase($this->mGoods,$pos);
                 $this->mDirty  = true;

+ 10 - 4
mobile/control/member_notice.php

@@ -8,6 +8,7 @@
  */
 require_once (BASE_ROOT_PATH . '/helper/special_helper.php');
 require_once (BASE_ROOT_PATH . '/helper/goods_helper.php');
+require_once (BASE_ROOT_PATH . '/helper/user_session/anotice.php');
 
 class member_noticeControl extends mbMemberControl
 {
@@ -86,21 +87,26 @@ class member_noticeControl extends mbMemberControl
             if($ret == false) {
                 Log::record("goods_common arrival_notice error.",Log::ERR);
             }
+            $anotice  = new user_session\anotice();
+            $anotice->add($goods_info['goods_id']);
         }
 
         return self::outsuccess(null);
     }
     public function delOp()
     {
-        $notice_id = $_POST['notice_id'];
-        if ($notice_id <= 0) {
+        $goods_id = $_POST['goods_id'];
+        if ($goods_id <= 0) {
             return self::outerr(errcode::ErrParamter,"请输入正确的参数.");
         }
 
         $mod_anotice = Model('arrival_notice');
-        $ret = $mod_anotice->delArrivalNotice(array('an_id' => $notice_id,'member_id' => $_SESSION['member_id']));
+        $ret = $mod_anotice->delArrivalNotice(array('goods_id' => $goods_id,'member_id' => $_SESSION['member_id']));
+        $anotice  = new user_session\anotice();
+        $anotice->del($goods_id);
+
         if($ret == false) {
-            Log::record("{$_SESSION['member_id']} del arraval notice an_id = {$notice_id} faile",Log::ERR);
+            Log::record("{$_SESSION['member_id']} del arraval notice $goods_id = {$goods_id} faile",Log::ERR);
         }
 
         return self::outsuccess(null);