예제 #1
0
 public static function hadCommented($userId, $orderId, $goodsId)
 {
     $ck = Cache::CK_GOODS_HAD_COMMENT . $userId . ':' . $orderId . ':' . $goodsId;
     $ret = Cache::get($ck);
     if ($ret === false) {
         $ret = DB::getDB()->fetchCount('g_goods_comment', array('user_id', 'goods_id', 'order_id'), array($userId, $goodsId, $orderId), array('and', 'and'));
         if ($ret !== false) {
             Cache::setex($ck, Cache::CK_GOODS_HAD_COMMENT_EXPIRE, (string) $ret);
         }
     }
     return (int) $ret > 0;
 }
예제 #2
0
 public static function hadLiked($userId, $commentId)
 {
     $ck = Cache::CK_GOODS_COMMENT_HAD_LIKE . $commentId . ':' . $userId;
     $ret = Cache::get($ck);
     if ($ret === false) {
         $ret = DB::getDB()->fetchCount('g_goods_comment_like', array('comment_id', 'user_id'), array($commentId, $userId), array('and'));
         if ($ret !== false) {
             Cache::setex($ck, Cache::CK_GOODS_COMMENT_HAD_LIKE_EXPIRE, (string) $ret);
         }
     }
     return (int) $ret > 0;
 }
예제 #3
0
 public static function findAllValidSKUInfo($goodsId)
 {
     if (empty($goodsId)) {
         return array();
     }
     $ck = Cache::CK_GOODS_SKU . $goodsId;
     // TODO 商品被修改时一定要记得刷新缓存(比如供应商后台)
     $ret = Cache::get($ck);
     if ($ret !== false) {
         $ret = json_decode($ret, true);
     } else {
         $ret = DB::getDB()->fetchAll('g_goods_sku', '*', array('goods_id', 'state', 'sale_price>'), array($goodsId, self::SKU_ST_VALID, 0), array('and', 'and'));
         if ($ret !== false) {
             Cache::setex($ck, Cache::CK_GOODS_SKU_EXPIRE, json_encode($ret));
         }
     }
     return $ret === false ? array() : $ret;
 }
예제 #4
0
파일: CouponModel.php 프로젝트: noikiy/php
 public static function findSomeCouponsByIds($couponIds)
 {
     if (empty($couponIds)) {
         return array();
     }
     ksort($couponIds, SORT_NUMERIC);
     $idSet = implode(',', $couponIds);
     $ck = Cache::CK_COUPON_CFG_LIST_INFO . $idSet;
     $ret = Cache::get($ck);
     if ($ret !== false) {
         $ret = json_decode($ret, true);
     } else {
         $sql = "select * from m_coupon_cfg where id in ({$idSet})";
         $ret = DB::getDB()->rawQuery($sql);
         if ($ret !== false) {
             Cache::setex($ck, json_encode($ret), Cache::CK_COUPON_CFG_INFO_LIST_EXPIRE);
         }
     }
     return $ret === false ? array() : $ret;
 }
예제 #5
0
파일: UserModel.php 프로젝트: noikiy/php
 public static function findUserByPhone($phone, $fromDb = 'w')
 {
     if (empty($phone)) {
         return array();
     }
     $ck = Cache::CK_USER_INFO_FOR_PHONE . $phone;
     $ret = Cache::get($ck);
     if ($ret !== false) {
         $ret = json_decode($ret, true);
     } else {
         $ret = DB::getDB($fromDb)->fetchOne('u_user', '*', array('phone'), array($phone));
         if ($ret !== false) {
             Cache::set($ck, json_encode($ret));
         }
     }
     if (empty($ret)) {
         return array();
     }
     $ret['nickname'] = Util::emojiDecode($ret['nickname']);
     return $ret;
 }