Commit 61881115 authored by wwccw0591's avatar wwccw0591

Merge branch 'master_dev' of git.shenbd.com:qm-develop/shenbd into ccw

parents 31abf9fa d95cc2d2
<?php
echo 3333;
echo 3333333;
......@@ -113,7 +113,7 @@ class StoreController extends \Our\Controller_AbstractIndex {
$data = $this->req[\Our\NameConst::data];
$couponService = \Business\Coupon\CouponServiceModel::getInstance();
$couponTitles = $couponService->getStorePromotionCouponTitles($data);
$this->success($couponTitles);
$this->success($couponTitles);
}
}
\ No newline at end of file
......@@ -101,7 +101,7 @@ class Common
return $url;
}
function is_https() {
public static function is_https() {
if ( !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') {
return true;
} elseif ( isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https' ) {
......
......@@ -164,11 +164,21 @@ class CouponServiceModel extends \Business\AbstractModel{
}
$couponDao->db->doCommit();
\Our\RedisHelper::delCachedFunction(\Redis\Db13\MemberCouponRedisModel::getInstance(), array(&$memberCouponDao, 'getList'),array(),array($memberId));
\Our\RedisHelper::delCachedFunction(\Redis\Db13\CouponRedisModel::getInstance(), array(&$this, 'getStoreCouponsById'),array(),array($coupon['store_id']."_".$memberId));
return true;
}
/**
* 购物车多店下单涉及到赠券时使用
* @param $coupons
* @param $memberId
* @param int $orderId
* @return bool
* @throws \Error\OurExceptionModel
* @throws \Exception
* @throws \Our\Exception
*/
public function receiveCouponBatch($coupons,$memberId,$orderId=\Our\ApiConst::zero){
$dbName = \Our\DbNameConst::masterDBConnectName;
$couponDao = \DAO\Coupon\CouponModel::getInstance($dbName);
......@@ -259,7 +269,7 @@ class CouponServiceModel extends \Business\AbstractModel{
$this->validCouponStore($where);
$couponDao = \DAO\Coupon\CouponModel::getInstance();
$couponTitles = \Our\RedisHelper::cachedFunction(\Redis\Db13\CouponRedisModel::getInstance(), array(&$couponDao, 'getStorePromotionCouponList'),array($where['storeId']),\Our\ApiConst::oneHour,array($where['storeId']));
return $couponTitles;
return $couponTitles?$couponTitles:array();
}
/**
......@@ -268,9 +278,11 @@ class CouponServiceModel extends \Business\AbstractModel{
public function getStoreCoupons($where,$memberId = null){
$couponDao = \DAO\Coupon\CouponModel::getInstance();
$couponDao->validStoreCouponParam($where);
$couponList = \Our\RedisHelper::cachedFunction(\Redis\Db13\CouponRedisModel::getInstance(), array(&$this, 'getStoreCouponsById'),array($where['storeId'],$memberId),\Our\ApiConst::oneHour,array($where['storeId']));
$couponList = \Our\RedisHelper::cachedFunction(\Redis\Db13\CouponRedisModel::getInstance(), array(&$this, 'getStoreCouponsById'),array($where['storeId'],$memberId),\Our\ApiConst::oneHour,array($where['storeId']."_".$memberId));
if($couponList){
$couponList = array_values($couponList);
}else{
$couponList = array();
}
return $couponList;
}
......@@ -279,7 +291,7 @@ class CouponServiceModel extends \Business\AbstractModel{
$this->validCouponStore($where);
$couponDao = \DAO\Coupon\CouponModel::getInstance();
$couponDao->validStoreCouponParam($where);
$couponList = \Our\RedisHelper::cachedFunction(\Redis\Db13\CouponRedisModel::getInstance(), array(&$this, 'getStoreCouponsById'),array($where['storeId'],$memberId,true),\Our\ApiConst::oneHour,array($where['storeId']));
$couponList = \Our\RedisHelper::cachedFunction(\Redis\Db13\CouponRedisModel::getInstance(), array(&$this, 'getStoreCouponsById'),array($where['storeId'],$memberId,\Our\ApiConst::one),\Our\ApiConst::oneHour,array($where['storeId']."_".$memberId));
if($couponList){
$couponList = array_values($couponList);
if(count($couponList)>=\Our\ApiConst::defaultCouponTitleLength){
......@@ -315,7 +327,7 @@ class CouponServiceModel extends \Business\AbstractModel{
* @param $memberId 会员ID
* @return array|bool
*/
public function getStoreCouponsById($storeId,$memberId,$timeFlag = false){
public function getStoreCouponsById($storeId,$memberId,$timeFlag = \Our\ApiConst::zero){
$couponDao = \DAO\Coupon\CouponModel::getInstance();
$couponList = $couponDao->getStoreIndexCouponList($storeId,$timeFlag);
if(!$couponList){
......@@ -348,10 +360,12 @@ class CouponServiceModel extends \Business\AbstractModel{
if(in_array(\Our\ApiConst::availCouponState,$couponStates)){
$coupon['isGet'] = \Our\ApiConst::one;
}else{
$coupon['isGet'] = \Our\ApiConst::zero;
$coupon[ 'isGet'] = \Our\ApiConst::zero;
}
}
}
}else{
$coupon['isGet'] = \Our\ApiConst::zero;
}
unset($coupon['is_overlay']);
}
......
......@@ -75,6 +75,13 @@ class EvaluationServiceModel extends \Business\AbstractModel {
$images = $v['images'];
if(!is_array($images)) $images = json_decode($images, true);
$images ? $data['goods'][$k]['haveImg'] = 1 : $data['goods'][$k]['haveImg'] = 0;
if($data['goods'][$k]['haveImg'] = 1) {
foreach ($images as &$image) {
if($image) {
$image = pathinfo($image)['basename'];
}
}
}
$evaluation['geval_image'] = serialize($images);
$goodsInstance = \DAO\GoodsModel::getInstance();
$evaluation['geval_goods_commonid'] = $orderGoods[$v['goodsId']]['goods_commonid'];
......@@ -98,7 +105,7 @@ class EvaluationServiceModel extends \Business\AbstractModel {
//更新商品评分
$statisticsDb6Redis = \Redis\Db6\StatisticsRedisModel::getInstance();
//goods_common
$grade = \DAO\GoodsCommonModel::getInstance()->getGrade($v['goodsCommonId']);
$grade = \DAO\GoodsScoreStatisticsModel::getInstance()->getGrade($v['goodsCommonId']);
$grade['evaluation_score'] = $grade['evaluation_score']+intval($v['scores']);
$grade['evaluation_number'] = $grade['evaluation_number'] + 1;
$v['haveImg'] ? $grade['evaluation_img_number'] += 1 : $grade['evaluation_img_number'] = $grade['evaluation_img_number'];
......@@ -147,7 +154,7 @@ class EvaluationServiceModel extends \Business\AbstractModel {
$resultStore = \DAO\EvaluateStoreModel::getInstance()->insert($evaluateStore);
if($resultStore){
//更新店铺评分
$grade = \DAO\StoreModel::getInstance()->getGrade($order['store_id']);
$grade = \DAO\StoreScoreStatisticsModel::getInstance()->getGrade($order['store_id']);
$grade['evaluation_score'] = $grade['evaluation_score']+intval($data['descCredit'])+intval($data['serviceCredit'])+intval($data['deliveryCredit']);
$grade['evaluation_number'] = $grade['evaluation_number'] + 1;
$statisticsDb6Redis = \Redis\Db6\StatisticsRedisModel::getInstance();
......
......@@ -23,6 +23,9 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
public function getGroupGoods($param){
$groupId = intval($param['groupId']);
$groupList = $this->getPBundlingListByBlIds(array($groupId));
if(!$groupList){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyPBundlingdForOrder);
}
$data = $groupList[0];
if($data['goodsCountFlag'] === false){
$data['state'] = 0;
......
......@@ -132,7 +132,7 @@ class StoreServiceModel extends \Business\AbstractModel{
$favType = 1;
}
}
return array('storeLabel'=>$storeLabel,'storeName'=>$storeInfo['store_name'],'grade'=>$grade,'fansCount'=>$storeInfo['store_collect'],'favType'=>$favType,'monthlySalesCount'=>$monthlySalesCount,'defaultDeliveryTime'=>$defaultDeliveryTime,'freeShippingPrice'=>$storeInfo['free_shipping_price'],'storeDistance'=>$distince,'storeNotice'=>$storeInfo['store_notice'],'startShippingPrice'=>$storeInfo['start_shipping_price'],'memberId'=>$storeInfo['member_id'],'inStoreService'=>$in_store_service_flag,'adv'=>$adv,'memberId'=>$storeInfo['member_id']);
return array('storeLabel'=>$storeLabel,'storeName'=>$storeInfo['store_name'],'grade'=>$grade,'fansCount'=>\DAO\FavoritesStoreModel::getInstance()->getFavoritesStoreCountByStoreId($storeId),'favType'=>$favType,'monthlySalesCount'=>$monthlySalesCount,'defaultDeliveryTime'=>$defaultDeliveryTime,'freeShippingPrice'=>$storeInfo['free_shipping_price'],'storeDistance'=>$distince,'storeNotice'=>$storeInfo['store_notice'],'startShippingPrice'=>$storeInfo['start_shipping_price'],'memberId'=>$storeInfo['member_id'],'inStoreService'=>$in_store_service_flag,'adv'=>$adv,'memberId'=>$storeInfo['member_id']);
}
/**
......@@ -182,7 +182,7 @@ class StoreServiceModel extends \Business\AbstractModel{
$returnClass[] = $v['gc_name'];
}
}
return array('storeName'=>$storeInfo['store_name'],'storeLabel'=>$storeLabel,'fansCount'=>$storeInfo['store_collect'],'clazz'=>$returnClass,'address'=>$address,'storePhone'=>$storeInfo['store_phone'],'openingHours'=>$openingHours,'storeService'=>$storeInfo['store_notice'],"qualificationImage"=>$detailImg);
return array('storeName'=>$storeInfo['store_name'],'storeLabel'=>$storeLabel,'fansCount'=>\DAO\FavoritesStoreModel::getInstance()->getFavoritesStoreCountByStoreId($storeId),'clazz'=>$returnClass,'address'=>$address,'storePhone'=>$storeInfo['store_phone'],'openingHours'=>$openingHours,'storeService'=>$storeInfo['store_notice'],"qualificationImage"=>$detailImg);
}
public function getRecommendGoodsCache($param,$memberId){
$recommendGoods = \Our\RedisHelper::cachedFunction(\Redis\Db6\StoreGoodsClassRedisModel::getInstance(),array(&$this, 'getRecommendGoods'),array($param,$memberId),\Our\ApiConst::oneDaySecond,array(intval($param['storeId'])));
......@@ -316,7 +316,7 @@ class StoreServiceModel extends \Business\AbstractModel{
$imgArr[] = $file_name;
}
}else{
$imgArr[] = $image;
$imgArr[] = pathinfo($image)['basename'];
}
}
$insert = array();
......@@ -359,6 +359,8 @@ class StoreServiceModel extends \Business\AbstractModel{
$return = $FavoritesStoreInstance->insertOrUpdate(array('member_id'=>$memberId,'store_id'=>$storeId,'fav_time'=>time()));
if((int)$return > 0){
//更新店铺收藏数
$FavoritesStoreInstance->getFavoritesStoreCountByStoreId($storeId, 1);
//删除缓存
\Our\RedisHelper::delCachedFunction(\Redis\Db6\FavoritesStoreRedisModel::getInstance(),array(&$FavoritesStoreInstance, 'getOne'),array('*',array('store_id'=>$storeId,'member_id'=>$memberId)),array($memberId));
\Our\RedisHelper::delCachedFunction(\Redis\Db6\FavoritesStoreRedisModel::getInstance(),array(&$FavoritesStoreInstance, 'getList'),array(),array($memberId));
......
......@@ -39,7 +39,7 @@ class FeedBackServiceModel extends \Business\AbstractModel
$imgArr[] = $file_name;
}
}else{
$imgArr[] = $image;
$imgArr[] = pathinfo($image)['basename'];
}
}
$insert = array();
......
......@@ -105,7 +105,7 @@ class FootprintServiceModel extends \Business\AbstractModel
$field = 'bl_id AS blId,bl_name AS name,bl_title,store_id,store_name,bl_state,bl_quota_starttime,bl_image,bl_storage,bl_discount_price AS discountPrice,bl_sum_price AS sumPrice,bl_quota_endtime AS endTime,image,is_transport,transport_id';
$pbundlingInstance = \DAO\PBundlingModel::getInstance();
$where2 = ' bl_id in ('.implode(',',$groupIds).')';
$groupList = \Our\RedisHelper::cachedFunction(\Redis\Db4\PBundlingRedisModel::getInstance(), array(&$pbundlingInstance, 'getList'), array($field,$where2), \Our\ApiConst::oneDaySecond);
$groupList = \Our\RedisHelper::cachedFunction(\Redis\Db4\PBundlingRedisModel::getInstance(), array(&$pbundlingInstance, 'getList'), array($field,$where2), \Our\ApiConst::oneMinute);
if($groupList) {
$dates = array_column($browseList,'browsedate','group_id');
foreach ($groupList as $group) {
......
......@@ -121,7 +121,7 @@ class MemberCenterServiceModel extends \Business\AbstractModel
if(is_array($list) && !empty($list)){
foreach ($list as $v){
$v['evaluation_score'] ? $grade = number_format(($v['evaluation_score']/3/$v['evaluation_number']),1,'.',''):$grade = '5.0';
$stores[] = array('favid'=>$v['favid'],'storeId'=>$v['store_id'],'storeLabel'=>\DAO\StoreModel::getInstance()->getStoreLabelSrc($v['store_label']),'storeName'=>$v['store_name'],'grade'=>$grade,'collectCount'=>$v['store_collect']?$v['store_collect']:0);
$stores[] = array('favid'=>$v['favid'],'storeId'=>$v['store_id'],'storeLabel'=>\DAO\StoreModel::getInstance()->getStoreLabelSrc($v['store_label']),'storeName'=>$v['store_name'],'grade'=>$grade,'collectCount'=>$favoritesInstance->getFavoritesStoreCountByStoreId($v['store_id']));
}
}
return array('stores'=>$stores,'totalCount'=>$totalCount);
......@@ -140,18 +140,32 @@ class MemberCenterServiceModel extends \Business\AbstractModel
\Error\ErrorModel::throwException(\Error\CodeConfigModel::cancleCollectionStore);
}
$FavoritesStoreInstance = \DAO\FavoritesStoreModel::getInstance();
$storeIds = array();
if(is_array($ids)){
$ids = array_map(function($v){
return intval($v);
},$ids);
$return = $FavoritesStoreInstance->update(array('fav_type'=>0),'store_id in ('.implode(',',$ids).')',true,$memberId);
$list = $FavoritesStoreInstance->selectList(array('store_id'=>array('in',$ids),'member_id'=>$memberId,'fav_type'=>1),'store_id');
if($list) {
$storeIds = array_column($list, 'store_id');
$return = $FavoritesStoreInstance->update(array('fav_type'=>0),'store_id in ('.implode(',',$ids).')',true,$memberId);
}
}else{
if(strpos($ids,']') !== false ) {
$ids = json_decode($ids, true);
$return = $FavoritesStoreInstance->update(array('fav_type'=>0),'store_id in ('.implode(',',$ids).')',true,$memberId);
$list = $FavoritesStoreInstance->selectList(array('store_id'=>array('in',$ids),'member_id'=>$memberId,'fav_type'=>1),'store_id');
if($list) {
$storeIds = array_column($list, 'store_id');
$return = $FavoritesStoreInstance->update(array('fav_type'=>0),'store_id in ('.implode(',',$ids).')',true,$memberId);
}
}else{
$ids = intval($ids);
$return = $FavoritesStoreInstance->update(array('fav_type'=>0),array('store_id'=>$ids,'member_id'=>$memberId));
$one = $FavoritesStoreInstance->getOne('store_id',array('store_id'=>$ids,'member_id'=>$memberId,'fav_type'=>1));
if($one) {
$storeIds = array($one['store_id']);
$return = $FavoritesStoreInstance->update(array('fav_type'=>0),array('store_id'=>$ids,'member_id'=>$memberId));
}
}
}
if($return === false) {
......@@ -159,6 +173,10 @@ class MemberCenterServiceModel extends \Business\AbstractModel
}
if(($return = (int)$return) > 0){
//删除缓存
foreach ($storeIds as $storeId) {
//更新店铺收藏数
$FavoritesStoreInstance->getFavoritesStoreCountByStoreId($storeId, -1);
}
if(is_array($ids) && count($ids) <= 20){
foreach ($ids as $v){
\Our\RedisHelper::delCachedFunction(\Redis\Db6\FavoritesStoreRedisModel::getInstance(),array(&$FavoritesStoreInstance, 'getOne'),array('*',array('store_id'=>$v,'member_id'=>$memberId)),array($memberId));
......
......@@ -150,7 +150,7 @@ class CouponModel extends \DAO\AbstractModel {
*/
public function getStorePromotionCouponList($storeId){
$field = $this->availStoreIndexField;
$where = ' and store_id in( '.$storeId.',0) and type<>1';
$where = ' and store_id ='.$storeId.' and type<>1';
$this->setDb($this->dbName);
$coupons = $this->getOnlineCouponList($where,$field);
......@@ -215,7 +215,7 @@ class CouponModel extends \DAO\AbstractModel {
*/
public function getStoreCouponList($storeId){
$field = $this->availStoreIndexField;
$where = ' and store_id in( '.$storeId.',0)';
$where = ' and store_id = '. $storeId ;
$coupons = $this->getOnlineCouponList($where,$field);
//$coupons = \Our\RedisHelper::cachedFunction(\Redis\Db13\CouponRedisModel::getInstance(), array(&$this, 'getOnlineCouponList'),array($where,$field),\Our\ApiConst::oneHour);
return $coupons;
......@@ -261,7 +261,7 @@ class CouponModel extends \DAO\AbstractModel {
* @param $storeId 店铺Id
* @return array
*/
public function getStoreIndexCouponList($storeId,$timeFlag= false){
public function getStoreIndexCouponList($storeId,$timeFlag= \Our\ApiConst::zero){
$coupons = $this->getStoreCouponList($storeId);
if($coupons){
$result = array();
......
......@@ -86,7 +86,21 @@ class FavoritesStoreModel extends \DAO\AbstractModel {
$sql = \Our\Common::format($baseSql, $data['member_id'], $data['store_id'],$data['fav_time']);
return $this->db->insert($this->_tableName)->query($sql);
}
public function getFavoritesStoreCountByStoreId($storeId, $num = 0) {
$statisticsDb6Redis = \Redis\Db6\StatisticsRedisModel::getInstance();
$collectCount = $statisticsDb6Redis->tableCacheGet('storeCollectCount:'.$storeId);
if($collectCount === false) {
$collectCount = $this->getFavoritesStoreCount(array('store_id'=>$storeId,'fav_type'=>1));
$statisticsDb6Redis->tableCacheSet('storeCollectCount:'.$storeId, $collectCount, \Our\ApiConst::sevenDaySecond);
return $collectCount;
}
if($num == 1) {
$collectCount = $statisticsDb6Redis->tableIncr('storeCollectCount:'.$storeId);
}elseif ($num == -1) {
$collectCount = $statisticsDb6Redis->tableDecr('storeCollectCount:'.$storeId);
}
return $collectCount;
}
/**
* 批量插入关注数据
* @param $datas
......
......@@ -33,7 +33,11 @@ class GoodsAttributeModel extends \DAO\AbstractModel {
$productData = [];
if(is_array($data) && !empty($data)){
foreach ($data as $v){
$productData[] = array('attrName'=>$v['attribute'],'attrValue'=>unserialize($v['attribute_value']));
$attrValue = unserialize($v['attribute_value']);
if(!is_array($attrValue)) {
$attrValue = array($attrValue);
}
$productData[] = array('attrName'=>$v['attribute'],'attrValue'=>$attrValue);
}
}
return $productData;
......
......@@ -100,88 +100,7 @@ class GoodsCommonModel extends \DAO\AbstractModel {
return $data->rows;
}
/**
* 获取优惠券对应商品列表(指定品类)
* @param $where
* @param $field
* @param $limit
* @return mixed
*/
// public function getCouponClassGoods($where,$field,$limit){
// $this->setDb();
// return $this->db->select($field)->from($this->_tableName)->join('han_store_coupon_goods_class','han_store_coupon_goods_class.gc_id = '.$this->_tableName.'.gc_id_1','inner')->where($where)->where('goods_verify = 1')->where('goods_state = 1')->limit($limit[0],$limit[1])->fetchAll();
// }
/**
* 获取优惠券对应商品列表(指定品类)(需要获取销售价格)
* @param $where
* @param $field
* @param $limit
* @param $actIds
*/
// public function getCouponClassGoodsWithSale($where,$field,$limit,$actIds){
// $this->setDb();
// $str = "select ".$field." FROM ".$this->_tableName." INNER JOIN han_store_coupon_goods_class on han_store_coupon_goods_class.gc_id = han_goods_common.gc_id_1 LEFT JOIN (SELECT MIN(discount_price) discount_price,goods_commonid,goods_id FROM han_sale_goods where sale_act_id in(".implode(',',$actIds).") GROUP BY goods_commonid) a on (han_goods_common.goods_commonid = a.goods_commonid) ";
// $str .= 'where(goods_verify = 1) AND (goods_state = 1) AND ';
// $str .= $where;
// $str .=" limit {$limit[0]},{$limit[1]}";
// $data = $this->db->query($str);
// return $data->rows;
// }
/**
* 获取优惠券对应商品列表(指定商品)
* @param $where
* @param $field
* @param $limit
* @return mixed
*/
// public function getCouponGoods($where,$field,$limit){
// $this->setDb();
// return $this->db->select($field)->from($this->_tableName)->join('han_store_coupon_goods','han_store_coupon_goods.goods_commonid = '.$this->_tableName.'.goods_commonid','inner')->where($where)->where('goods_verify = 1')->where('goods_state = 1')->limit($limit[0],$limit[1])->fetchAll();
// }
/**
* 获取优惠券对应商品列表(指定商品)(需要获取销售价格)
* @param $where
* @param $field
* @param $limit
* @param $actIds
*/
// public function getCouponGoodsWithSale($where,$field,$limit,$actIds){
// $this->setDb();
// $str = "select ".$field." FROM ".$this->_tableName." INNER JOIN han_store_coupon_goods on han_store_coupon_goods.goods_commonid = han_goods_common.goods_commonid LEFT JOIN (SELECT MIN(discount_price) discount_price,goods_commonid,goods_id FROM han_sale_goods where sale_act_id in(".implode(',',$actIds).") GROUP BY goods_commonid) a on (han_goods_common.goods_commonid = a.goods_commonid) ";
// $str .= 'where(goods_verify = 1) AND (goods_state = 1) AND ';
// $str .= $where;
// $str .=" limit {$limit[0]},{$limit[1]}";
// $data = $this->db->query($str);
// return $data->rows;
// }
/**
* 获取商品评分
* @param $StoreId
* @return mixed
*/
public function getGrade($goodsCommonId,$commonInfo = null){
$statisticsDb6Redis = \Redis\Db6\StatisticsRedisModel::getInstance();
$grade = $statisticsDb6Redis->tableHGet('goodsCommon',$goodsCommonId);
if($grade === false){
if(!$commonInfo){
$goodsScoreDAO = \DAO\GoodsScoreStatisticsModel::getInstance();
$commonInfo = \Our\RedisHelper::cachedFunction(\Redis\Db4\GoodsScoreStatisticsRedisModel::getInstance(),array(&$goodsScoreDAO, 'getOne'),array('*',array('goods_commonid'=>$goodsCommonId)),\Our\ApiConst::oneDaySecond,array($goodsCommonId));
if($commonInfo === false){
$commonInfo['evaluation_number'] = 0;
$commonInfo['evaluation_img_number'] = 0;
$commonInfo['evaluation_score'] = 0;
}
}
$grade = array();
$grade['evaluation_score'] = $commonInfo['evaluation_score'];
$grade['evaluation_number'] = $commonInfo['evaluation_number'];
$grade['evaluation_img_number'] = $commonInfo['evaluation_img_number'];
$statisticsDb6Redis->tableHSet('goodsCommon',$goodsCommonId,serialize($grade));
return $grade;
}
return unserialize($grade);
}
/**
* 获取图片oss路径
* @param $goodsImg 图片名
......
......@@ -59,6 +59,33 @@ class GoodsScoreStatisticsModel extends \DAO\AbstractModel {
}
return true;
}
/**
* 获取商品评分
* @param $StoreId
* @return mixed
*/
public function getGrade($goodsCommonId,$commonInfo = null){
$statisticsDb6Redis = \Redis\Db6\StatisticsRedisModel::getInstance();
$grade = $statisticsDb6Redis->tableHGet('goodsCommon',$goodsCommonId);
if($grade === false){
if(!$commonInfo){
$goodsScoreDAO = \DAO\GoodsScoreStatisticsModel::getInstance();
$commonInfo = \Our\RedisHelper::cachedFunction(\Redis\Db4\GoodsScoreStatisticsRedisModel::getInstance(),array(&$goodsScoreDAO, 'getOne'),array('*',array('goods_commonid'=>$goodsCommonId)),\Our\ApiConst::oneDaySecond,array($goodsCommonId));
if($commonInfo === false){
$commonInfo['evaluation_number'] = 0;
$commonInfo['evaluation_img_number'] = 0;
$commonInfo['evaluation_score'] = 0;
}
}
$grade = array();
$grade['evaluation_score'] = $commonInfo['evaluation_score'];
$grade['evaluation_number'] = $commonInfo['evaluation_number'];
$grade['evaluation_img_number'] = $commonInfo['evaluation_img_number'];
$statisticsDb6Redis->tableHSet('goodsCommon',$goodsCommonId,serialize($grade));
return $grade;
}
return unserialize($grade);
}
/**
* 类实例
*
......
......@@ -38,7 +38,7 @@ class PBundlingModel extends \DAO\AbstractModel {
if(is_array($where)){
$where = $this->db->getSqlWhereByArray($where);
}
return $this->db->select($field)->from($this->_tableName)->where($where)->where("bl_quota_starttime <= ".time())->where('bl_quota_endtime >= '.time())->where('bl_state=1')->limit($limit[0],$limit[1])->fetchAll();
return $this->db->select($field)->from($this->_tableName)->where($where)->where("bl_quota_starttime <= ".time())->where('bl_quota_endtime >= '.time())->where('bl_state=1')->where('is_del=0')->limit($limit[0],$limit[1])->fetchAll();
}
public function getImgPath($image){
if($image){
......@@ -48,11 +48,11 @@ class PBundlingModel extends \DAO\AbstractModel {
public function getDetail($where,$field,$limit=false){
$this->setDb($this->dbName);
return $this->db->select($field)->from($this->_tableName)->join('han_p_bundling_goods',"han_p_bundling_goods.bl_id = han_p_bundling.bl_id",'inner')->where($where)->where("bl_quota_starttime <= ".time())->where('bl_quota_endtime >= '.time())->where('bl_state=1')->limit($limit[0],$limit[1])->fetchAll();
return $this->db->select($field)->from($this->_tableName)->join('han_p_bundling_goods',"han_p_bundling_goods.bl_id = han_p_bundling.bl_id",'inner')->where($where)->where("bl_quota_starttime <= ".time())->where('bl_quota_endtime >= '.time())->where('bl_state=1')->where('is_del=0')->limit($limit[0],$limit[1])->fetchAll();
}
public function getCount($where){
$this->setDb($this->dbName);
return $this->db->from($this->_tableName)->where($where)->where("bl_quota_starttime <= ".time())->where('bl_quota_endtime >= '.time())->where('bl_state=1')->fetchNum();
return $this->db->from($this->_tableName)->where($where)->where("bl_quota_starttime <= ".time())->where('bl_quota_endtime >= '.time())->where('bl_state=1')->where('is_del=0')->fetchNum();
}
......
......@@ -149,88 +149,6 @@ class GoodsCommonStorageModel extends \DAO\AbstractModel {
return $data->rows;
}
/**
* 获取优惠券对应商品列表(指定品类)
* @param $where
* @param $field
* @param $limit
* @return mixed
*/
// public function getCouponClassGoods($where,$field,$limit){
// $this->setDb();
// return $this->db->select($field)->from($this->_tableName)->join('han_store_coupon_goods_class','han_store_coupon_goods_class.gc_id = '.$this->_tableName.'.gc_id_1','inner')->where($where)->where('goods_verify = 1')->where('goods_state = 1')->limit($limit[0],$limit[1])->fetchAll();
// }
/**
* 获取优惠券对应商品列表(指定品类)(需要获取销售价格)
* @param $where
* @param $field
* @param $limit
* @param $actIds
*/
// public function getCouponClassGoodsWithSale($where,$field,$limit,$actIds){
// $this->setDb();
// $str = "select ".$field." FROM ".$this->_tableName." INNER JOIN han_store_coupon_goods_class on han_store_coupon_goods_class.gc_id = han_goods_common.gc_id_1 LEFT JOIN (SELECT MIN(discount_price) discount_price,goods_commonid,goods_id FROM han_sale_goods where sale_act_id in(".implode(',',$actIds).") GROUP BY goods_commonid) a on (han_goods_common.goods_commonid = a.goods_commonid) ";
// $str .= 'where(goods_verify = 1) AND (goods_state = 1) AND ';
// $str .= $where;
// $str .=" limit {$limit[0]},{$limit[1]}";
// $data = $this->db->query($str);
// return $data->rows;
// }
/**
* 获取优惠券对应商品列表(指定商品)
* @param $where
* @param $field
* @param $limit
* @return mixed
*/
// public function getCouponGoods($where,$field,$limit){
// $this->setDb();
// return $this->db->select($field)->from($this->_tableName)->join('han_store_coupon_goods','han_store_coupon_goods.goods_commonid = '.$this->_tableName.'.goods_commonid','inner')->where($where)->where('goods_verify = 1')->where('goods_state = 1')->limit($limit[0],$limit[1])->fetchAll();
// }
/**
* 获取优惠券对应商品列表(指定商品)(需要获取销售价格)
* @param $where
* @param $field
* @param $limit
* @param $actIds
*/
// public function getCouponGoodsWithSale($where,$field,$limit,$actIds){
// $this->setDb();
// $str = "select ".$field." FROM ".$this->_tableName." INNER JOIN han_store_coupon_goods on han_store_coupon_goods.goods_commonid = han_goods_common.goods_commonid LEFT JOIN (SELECT MIN(discount_price) discount_price,goods_commonid,goods_id FROM han_sale_goods where sale_act_id in(".implode(',',$actIds).") GROUP BY goods_commonid) a on (han_goods_common.goods_commonid = a.goods_commonid) ";
// $str .= 'where(goods_verify = 1) AND (goods_state = 1) AND ';
// $str .= $where;
// $str .=" limit {$limit[0]},{$limit[1]}";
// $data = $this->db->query($str);
// return $data->rows;
// }
/**
* 获取商品评分
* @param $StoreId
* @return mixed
*/
public function getGrade($goodsCommonId,$commonInfo = null){
$statisticsDb6Redis = \Redis\Db6\StatisticsRedisModel::getInstance();
$grade = $statisticsDb6Redis->tableHGet('goodsCommon',$goodsCommonId);
if($grade === false){
if(!$commonInfo){
$goodsScoreDAO = \DAO\GoodsScoreStatisticsModel::getInstance();
$commonInfo = \Our\RedisHelper::cachedFunction(\Redis\Db4\GoodsScoreStatisticsRedisModel::getInstance(),array(&$goodsScoreDAO, 'getOne'),array('*',array('goods_commonid'=>$goodsCommonId)),\Our\ApiConst::oneDaySecond,array($goodsCommonId));
if($commonInfo === false){
$commonInfo['evaluation_number'] = 0;
$commonInfo['evaluation_img_number'] = 0;
$commonInfo['evaluation_score'] = 0;
}
}
$grade = array();
$grade['evaluation_score'] = $commonInfo['evaluation_score'];
$grade['evaluation_number'] = $commonInfo['evaluation_number'];
$grade['evaluation_img_number'] = $commonInfo['evaluation_img_number'];
$statisticsDb6Redis->tableHSet('goodsCommon',$goodsCommonId,serialize($grade));
return $grade;
}
return unserialize($grade);
}
/**
* 获取图片oss路径
* @param $goodsImg 图片名
......
......@@ -50,32 +50,7 @@ class StoreModel extends \DAO\AbstractModel
return $store;
}
/**
* 获取店铺评分
* @param $StoreId
* @return mixed
*/
public function getGrade($StoreId, $storeInfo = null)
{
$statisticsDb6Redis = \Redis\Db6\StatisticsRedisModel::getInstance();
$grade = $statisticsDb6Redis->tableHGet('store', $StoreId);
if ($grade === false) {
if (!$storeInfo) {
$storeScoreDAO = \DAO\StoreScoreStatisticsModel::getInstance();
$storeInfo = \Our\RedisHelper::cachedFunction(\Redis\Db6\StoreScoreStatisticsRedisModel::getInstance(), array(&$storeScoreDAO, 'getOne'), array('*',array('store_id'=>$StoreId)),\Our\ApiConst::oneDaySecond);
if($storeInfo === false){
$storeInfo['evaluation_score'] = 0;
$storeInfo['evaluation_number'] = 0;
}
}
$grade = array();
$grade['evaluation_score'] = $storeInfo['evaluation_score'];
$grade['evaluation_number'] = $storeInfo['evaluation_number'];
$statisticsDb6Redis->tableHSet('store', $StoreId, serialize($grade));
return $grade;
}
return unserialize($grade);
}
public function getInfoById($id, $field = '*', $isField = false)
{
......
......@@ -34,6 +34,63 @@ class StoreScoreStatisticsModel extends \DAO\AbstractModel {
$sql = \Our\Common::format($baseSql, $data['store_id'], $data['evaluation_score'],$data['evaluation_number']);
return $this->db->insert($this->_tableName)->query($sql);
}
public function insertAllOrUpdate($datas){
$this->setDb(\Our\DbNameConst::masterDBConnectName);
$error = 0;
$baseSql = "insert into {$this->_tableName}(store_id,evaluation_score,evaluation_number) values";
$insertAllSql = $baseSql;
for ($i = 0; $i < count($datas); $i++) {
$addSql = \Our\Common::format("({0},{1},{2}),", $datas[$i]['store_id'], $datas[$i]['evaluation_score'], $datas[$i]['evaluation_number']);
$insertAllSql .= $addSql;
if ($i % 1000 == 0 && $i != 0) {
$insertAllSql = rtrim($insertAllSql, ',');
$insertAllSql .= 'ON DUPLICATE KEY UPDATE num = VALUES(num),updatetime=VALUES(updatetime)';
$one = $this->db->insert()->query($insertAllSql);
if ($one === false) {
$error++;
}
$insertAllSql = $baseSql;
}
}
if ($insertAllSql != $baseSql) {
$insertAllSql = rtrim($insertAllSql, ',');
$insertAllSql .= 'ON DUPLICATE KEY UPDATE num = VALUES(num),updatetime=VALUES(updatetime)';
$one = $this->db->insert($this->_tableName)->query($insertAllSql);
if ($one === false) {
$error++;
}
}
if ($error > 0) {
return false;
}
return true;
}
/**
* 获取店铺评分、收藏
* @param $StoreId
* @return mixed
*/
public function getGrade($StoreId, $storeInfo = null)
{
$statisticsDb6Redis = \Redis\Db6\StatisticsRedisModel::getInstance();
$grade = $statisticsDb6Redis->tableHGet('store', $StoreId);
if ($grade === false) {
if (!$storeInfo) {
$storeScoreDAO = \DAO\StoreScoreStatisticsModel::getInstance();
$storeInfo = \Our\RedisHelper::cachedFunction(\Redis\Db6\StoreScoreStatisticsRedisModel::getInstance(), array(&$storeScoreDAO, 'getOne'), array('*',array('store_id'=>$StoreId)),\Our\ApiConst::oneDaySecond);
if($storeInfo === false){
$storeInfo['evaluation_score'] = 0;
$storeInfo['evaluation_number'] = 0;
}
}
$grade = array();
$grade['evaluation_score'] = $storeInfo['evaluation_score'];
$grade['evaluation_number'] = $storeInfo['evaluation_number'];
$statisticsDb6Redis->tableHSet('store', $StoreId, serialize($grade));
return $grade;
}
return unserialize($grade);
}
/**
* 类实例
*
......
......@@ -63,4 +63,11 @@ class AbstractModel extends \Redis\AbstractModel {
public function tableDel($h){
return $this->del($this->calcKey($h));
}
public function tableIncr($h) {
return $this->incr($this->calcKey($h));
}
public function tableDecr($h) {
return $this->decr($this->calcKey($h));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment