Commit 4ad9e411 authored by liuyuzhen's avatar liuyuzhen

店铺优惠券排序问题:已领取优惠券往后排

parent 18c69bb3
......@@ -281,6 +281,7 @@ class CouponServiceModel extends \Business\AbstractModel{
$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);
$couponList =$this->sortCouponList($couponList);
}else{
$couponList = array();
}
......@@ -294,6 +295,7 @@ class CouponServiceModel extends \Business\AbstractModel{
$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);
$couponList = $this->sortCouponList($couponList);
if(count($couponList)>=\Our\ApiConst::defaultCouponTitleLength){
$couponTitleArray= array_slice($couponList,0,\Our\ApiConst::defaultCouponTitleLength);
}else{
......@@ -388,6 +390,14 @@ class CouponServiceModel extends \Business\AbstractModel{
\Our\RedisHelper::delCachedFunction(\Redis\Db13\CouponRedisModel::getInstance(), array(&$this, 'getStoreCouponsById'),array(),array($storeId));
}
public function sortCouponList($couponList){
foreach($couponList as $key => $coupon){
$isGet[$key] = $coupon['isGet'];
}
array_multisort($isGet, SORT_ASC, $couponList);
return $couponList;
}
/**
* 类实例
*/
......
......@@ -40,6 +40,9 @@ class StoreTopSaleGoodsModel extends \DAO\AbstractModel{
public function getList($where){
$this->setDb();
if(is_array($where)){
$where = $this->db->getSqlWhereByArray($where);
}
return $this->db->select('goods_commonid as goodsCommonId,goods_name as goodsName,goods_image as goodsImage,goods_score as evalScore')->from($this->_tableName)->where($where)->fetchAll();
}
......@@ -58,10 +61,10 @@ class StoreTopSaleGoodsModel extends \DAO\AbstractModel{
if ($storeGoods) {
$orderGoods = empty($orderGoods)?$storeGoods:array_merge($orderGoods, $storeGoods);
}else{
$singleStoreGoods = $this->getList(array('store_id'=>$storeId));
$singleStoreGoods = $this->getList(array('store_id'=>$storeId,'goods_commonid'=>array('neq','')));
if($singleStoreGoods){
$ordesGoods = empty($orderGoods)?$singleStoreGoods:array_merge($orderGoods,$singleStoreGoods);
$storeTopSaleGoodsRedis->update($storeId,$singleStoreGoods);
$storeTopSaleGoodsRedis->update($storeId,$singleStoreGoods,\Our\ApiConst::oneDaySecond);
}
}
}
......
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