Commit d5833144 authored by liuyuzhen's avatar liuyuzhen

购物车问题

parent f98e5e28
...@@ -36,7 +36,6 @@ class CartController extends \Our\Controller_AbstractApi{ ...@@ -36,7 +36,6 @@ class CartController extends \Our\Controller_AbstractApi{
$data['pageIndex'] = $pageIndex; $data['pageIndex'] = $pageIndex;
$data['pageSize'] = $pageSize; $data['pageSize'] = $pageSize;
$storeCartList = $cartService->getCart($data,$this->memberId); $storeCartList = $cartService->getCart($data,$this->memberId);
$pBundlingService = \Business\Goods\GroupSaleServiceModel::getInstance(); $pBundlingService = \Business\Goods\GroupSaleServiceModel::getInstance();
$sess=\Yaf\Session::getInstance(); $sess=\Yaf\Session::getInstance();
$currentAddress = $sess->get('currentAddress'); $currentAddress = $sess->get('currentAddress');
......
...@@ -8,6 +8,8 @@ class GroupSaleServiceModel extends \Business\AbstractModel { ...@@ -8,6 +8,8 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
private $pBundingField = 'han_p_bundling.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,snapshot_id,goods_freight,goods_free'; private $pBundingField = 'han_p_bundling.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,snapshot_id,goods_freight,goods_free';
private $pBundingFieldWithDel = 'han_p_bundling.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,snapshot_id,goods_freight,goods_free,is_del';
private $pBundingGoodsField = 'bl_count_price AS discountPrice,num,goods_id,bl_id'; private $pBundingGoodsField = 'bl_count_price AS discountPrice,num,goods_id,bl_id';
private $pBundingGoodsDetailField = 'goods_id,goods_commonid AS goodsCommonId,goods_name AS goodsName,goods_image,goods_spec,goods_storage AS goodsStorage,goods_price AS goodsPrice,goods_state,goods_verify,is_del'; private $pBundingGoodsDetailField = 'goods_id,goods_commonid AS goodsCommonId,goods_name AS goodsName,goods_image,goods_spec,goods_storage AS goodsStorage,goods_price AS goodsPrice,goods_state,goods_verify,is_del';
...@@ -116,7 +118,7 @@ class GroupSaleServiceModel extends \Business\AbstractModel { ...@@ -116,7 +118,7 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
}*/ }*/
//$pBundlingList = $this->getGroupListForCart($blIds); //$pBundlingList = $this->getGroupListForCart($blIds);
//var_dump($pBundlingList); //var_dump($pBundlingList);
$pBundlingList = $this->getPBundlingListByBlIds($blIds,\Our\DbNameConst::salveDBConnectName,true); $pBundlingList = $this->getPBundlingListByBlIds($blIds,\Our\DbNameConst::salveDBConnectName,array(),true,\Our\ApiConst::one);
$pBundlingList = $this->getResizeGroupSaleGoodsList($pBundlingList); $pBundlingList = $this->getResizeGroupSaleGoodsList($pBundlingList);
} }
$goodsCommonIds = $cartListData['goodsCommonIds']; $goodsCommonIds = $cartListData['goodsCommonIds'];
...@@ -150,7 +152,9 @@ class GroupSaleServiceModel extends \Business\AbstractModel { ...@@ -150,7 +152,9 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
if (!$pBundling) { if (!$pBundling) {
$tempObj['goodsState'] = \Our\ApiConst::cartGoodsOffline; $tempObj['goodsState'] = \Our\ApiConst::cartGoodsOffline;
} else if (!($pBundling['bl_state'] == \Our\ApiConst::one && ($pBundling['bl_quota_starttime'] < time() && $pBundling['endTime'] >= time()))||!$pBundling['goodsCountFlag']) { } else if(isset($pBundling['is_del'])&&$pBundling['is_del']==\Our\ApiConst::one){
$tempObj['goodsState'] = \Our\ApiConst::cartGoodsOffline;
}else if (!($pBundling['bl_state'] == \Our\ApiConst::one && ($pBundling['bl_quota_starttime'] < time() && $pBundling['endTime'] >= time()))||!$pBundling['goodsCountFlag']) {
$tempObj['goodsState'] = \Our\ApiConst::cartGoodsOffline; $tempObj['goodsState'] = \Our\ApiConst::cartGoodsOffline;
} else { } else {
if($pBundling['bl_storage']<=\Our\ApiConst::zero){ if($pBundling['bl_storage']<=\Our\ApiConst::zero){
...@@ -164,9 +168,11 @@ class GroupSaleServiceModel extends \Business\AbstractModel { ...@@ -164,9 +168,11 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
}else{ }else{
$tempObj['blChangeFlag'] = \Our\ApiConst::one; $tempObj['blChangeFlag'] = \Our\ApiConst::one;
} }
$tempPrice = \Goods\GoodsUtil::getInstance()->getRealPrice($pBundling['blId'],null,null,\Our\ApiConst::addBundingToCart,\Our\DbNameConst::salveDBConnectName); if($tempObj['goodsState'] != \Our\ApiConst::cartGoodsOffline){
if($tempPrice){ $tempPrice = \Goods\GoodsUtil::getInstance()->getRealPrice($pBundling['blId'],null,null,\Our\ApiConst::addBundingToCart,\Our\DbNameConst::salveDBConnectName);
$tempObj['goodsPrice'] = $tempPrice; if($tempPrice){
$tempObj['goodsPrice'] = $tempPrice;
}
} }
$tempObj['goodsImage'] = $pBundling['image']; $tempObj['goodsImage'] = $pBundling['image'];
...@@ -190,8 +196,10 @@ class GroupSaleServiceModel extends \Business\AbstractModel { ...@@ -190,8 +196,10 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
}else{ }else{
$tempObj['goodsState'] = \Our\ApiConst::cartGoodsOffline; $tempObj['goodsState'] = \Our\ApiConst::cartGoodsOffline;
} }
$price = \Goods\GoodsUtil::getInstance()->getRealPrice($tempCart['goods_id'],$memberId); if($tempObj['goodsState'] != \Our\ApiConst::cartGoodsOffline){
$tempObj['goodsPrice'] = $price?$price:$tempObj['goodsPrice']; $price = \Goods\GoodsUtil::getInstance()->getRealPrice($tempCart['goods_id'],$memberId);
$tempObj['goodsPrice'] = $price?$price:$tempObj['goodsPrice'];
}
} }
$tempObj['goodsAttr'] = $goodsDao->getFormatGoodsAttr($tempCart['goods_spec']); $tempObj['goodsAttr'] = $goodsDao->getFormatGoodsAttr($tempCart['goods_spec']);
$tempObj['goodsMid'] = $tempCart['goods_mid']; $tempObj['goodsMid'] = $tempCart['goods_mid'];
...@@ -303,12 +311,25 @@ class GroupSaleServiceModel extends \Business\AbstractModel { ...@@ -303,12 +311,25 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
* 获取组合销售商品列表 * 获取组合销售商品列表
* @param $blIds * @param $blIds
*/ */
public function getPBundlingListByBlIds($blIds,$dbName = \Our\DbNameConst::salveDBConnectName,$withKeyFlag= false){
/**
* @param $blIds
* @param string $dbName
* @param bool $withKeyFlag
* @param int $isDel 是否包含已经删除的数据(0:不包含已删除数据, 1 包含已删除数据)
* @return array|bool
* @throws \Our\Exception
*/
public function getPBundlingListByBlIds($blIds,$dbName = \Our\DbNameConst::salveDBConnectName,$limit=array(\Our\ApiConst::zero,\Our\ApiConst::five),$withKeyFlag= false,$isDel=\Our\ApiConst::zero){
if(!$blIds){ if(!$blIds){
return false; return false;
} }
$field = $this->pBundingField;
if($isDel==\Our\ApiConst::one){
$field = $this->pBundingFieldWithDel;
}
$pbundlingInstance = \DAO\PBundlingModel::getInstance(\Our\DbNameConst::salveDBConnectName); $pbundlingInstance = \DAO\PBundlingModel::getInstance(\Our\DbNameConst::salveDBConnectName);
$groupList = \Our\RedisHelper::cachedFunction(\Redis\Db4\PBundlingRedisModel::getInstance(),array(&$pbundlingInstance, 'getList'),array($this->pBundingField,array('bl_id'=>array('in',$blIds)),array(\Our\ApiConst::zero,\Our\ApiConst::five)),\Our\ApiConst::oneDaySecond,array(implode(',',$blIds))); $groupList = \Our\RedisHelper::cachedFunction(\Redis\Db4\PBundlingRedisModel::getInstance(),array(&$pbundlingInstance, 'getList'),array($field,array('bl_id'=>array('in',$blIds)),$limit,$isDel),\Our\ApiConst::oneDaySecond,array(implode(',',$blIds)));
$newGroupList = $this->getPBundlingList($groupList,$dbName,$withKeyFlag); $newGroupList = $this->getPBundlingList($groupList,$dbName,$withKeyFlag);
return $newGroupList; return $newGroupList;
} }
...@@ -536,7 +557,7 @@ class GroupSaleServiceModel extends \Business\AbstractModel { ...@@ -536,7 +557,7 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
//unset($goods_temp['goods_image']); //unset($goods_temp['goods_image']);
//unset($goods_temp['bl_id']); //unset($goods_temp['bl_id']);
//$goodsArray[] =$goods_temp; //unset($goods_temp['goods_image']); //$goodsArray[] =$goods_temp; //unset($goods_temp['goods_image']);
if(!$goods_temp['goods_state']==\Our\ApiConst::onlineGoodsState&&$goods_temp['goods_verify']==\Our\ApiConst::onlineGoodsVerify&&$goods_temp['is_del']==\Our\ApiConst::onlineGoodsDel){ if(!($goods_temp['goods_state']==\Our\ApiConst::onlineGoodsState&&$goods_temp['goods_verify']==\Our\ApiConst::onlineGoodsVerify&&$goods_temp['is_del']==\Our\ApiConst::onlineGoodsDel)){
$tempGroup['goodsCountFlag'] = false; $tempGroup['goodsCountFlag'] = false;
} }
if($tempGroup['bl_storage']>0&&floor($goods_temp['goodsStorage']/$goods_temp['num'])<$tempGroup['bl_storage']){ if($tempGroup['bl_storage']>0&&floor($goods_temp['goodsStorage']/$goods_temp['num'])<$tempGroup['bl_storage']){
......
...@@ -33,12 +33,28 @@ class PBundlingModel extends \DAO\AbstractModel { ...@@ -33,12 +33,28 @@ class PBundlingModel extends \DAO\AbstractModel {
// $where = array(); // $where = array();
// $groupList=$this->db->select($field)->from($this->_tableName)->where($where)->order('gmt_create','DESC')->fetchOne(); // $groupList=$this->db->select($field)->from($this->_tableName)->where($where)->order('gmt_create','DESC')->fetchOne();
// } // }
public function getList($field,$where,$limit = array(0,0)){
/**
* @param $field
* @param $where
* @param array $limit
* @param int $isDel 是否包含已删除数据(0:不包含,1包含)
* @return mixed
*/
public function getList($field,$where,$limit = [],$isDel = \Our\ApiConst::zero){
$this->setDb($this->dbName); $this->setDb($this->dbName);
if(is_array($where)){ if(is_array($where)){
$where = $this->db->getSqlWhereByArray($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')->where('is_del=0')->limit($limit[0],$limit[1])->fetchAll(); $this->db->select($field)->from($this->_tableName)->where($where)->where("bl_quota_starttime <= ".time())->where('bl_quota_endtime >= '.time())->where('bl_state=1');
if($isDel==\Our\ApiConst::zero){
$this->db->where('is_del=0');
}
if($limit){
$this->db->limit($limit[0],$limit[1]);
}
$result = $this->db->fetchAll();
return $result;
} }
public function getImgPath($image){ public function getImgPath($image){
if($image){ if($image){
......
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