Commit 30003491 authored by wwccw0591's avatar wwccw0591

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

parents 74cca24f 91cae03a
......@@ -36,7 +36,6 @@ class CartController extends \Our\Controller_AbstractApi{
$data['pageIndex'] = $pageIndex;
$data['pageSize'] = $pageSize;
$storeCartList = $cartService->getCart($data,$this->memberId);
$pBundlingService = \Business\Goods\GroupSaleServiceModel::getInstance();
$sess=\Yaf\Session::getInstance();
$currentAddress = $sess->get('currentAddress');
......
......@@ -41,5 +41,6 @@ class CouponController extends \Our\Controller_AbstractIndex{
$couponList = $couponService->getGoodsCoupons($data,$memberId);
$this->success($couponList);
}
}
......@@ -41,6 +41,8 @@ class OrderConfirmUtil {
private $storeMemos = array();
private $cartCacheDeleteFlag = false;
public function addOrder($data,$memberId,$currentAddress){
$storeCartData = $this->checkPostData($data,$memberId,$currentAddress);
//return $storeCartData;
......@@ -89,6 +91,7 @@ class OrderConfirmUtil {
$this->storeIds= array_keys($cartList['list']);
$this->storeMemos[$this->postData['storeId']] = isset($this->postData['storeMemo'])?$this->postData['storeMemo']:\Our\NameConst::emptyString;
}else{
$this->cartCacheDeleteFlag = true;
foreach($this->postData as $temp){
$this->checkOneStoreData($temp);
if(!$temp['cartIds']){
......@@ -513,10 +516,23 @@ class OrderConfirmUtil {
}
public function opCacheInfo(){
if($this->cartCacheDeleteFlag){
$this->delCartCache();
}
$this->deleteCacheInfo();
$this->pushSaleGoods();
}
public function delCartCache(){
$cartRedis = \Redis\Db7\CartRedisModel::getInstance();
$memberCartKey = \Our\NameConst::memberCartStorePrefix.$this->memberId;
$cartRedis->tableDel($memberCartKey);
foreach($this->storeIds as $tempStoreId){
$memberStoreCartsKey = \Our\NameConst::memberStoreCartsPrefix.$this->memberId.\Our\NameConst::underline.$tempStoreId;
$cartRedis->tableDel($memberStoreCartsKey);
}
}
public function pushSaleGoods(){
if($this->saleGoodsIds){
$saleGoodsDao = \DAO\SaleGoodsModel::getInstance();
......
......@@ -157,8 +157,8 @@ class AdvServiceModel extends \Business\AbstractModel{
$advMobileSql = \Our\Common::format($advMobileSql,$where['storeId'],$position,\Our\ApiConst::one,\Our\ApiConst::one);
$advMobileField = 'href,src,end_time,start_time';
$advMobileList = \Our\RedisHelper::cachedFunction(\Redis\Db9\AdvMobileRedisModel::getInstance(),array(&$advMobileDao, 'getList'),array($advMobileSql,$advMobileField,array('adv_id'=>\Our\NameConst::desc)),\Our\ApiConst::oneHour,array($where['storeId']));
if($advMobileList){
$advs = array();
if($advMobileList){
foreach($advMobileList as $adv){
if($adv['start_time']<=TIMESTAMP&&$adv['end_time']>TIMESTAMP){
$temp = array();
......@@ -167,7 +167,7 @@ class AdvServiceModel extends \Business\AbstractModel{
$advs[] = $temp;
}
}
}else{
}/*else{
$storeAdvPositionDao = \DAO\Adv\StoreAdvPositionModel::getInstance();
$storeAdvPosition = \Our\RedisHelper::cachedFunction(\Redis\Db9\StoreAdvPositionRedisModel::getInstance(),array(&$storeAdvPositionDao, 'find'),array(array('ap_id'=>$position)),\Our\ApiConst::oneHour,array($position));
if($storeAdvPosition&&$storeAdvPosition['default_content']){
......@@ -176,7 +176,7 @@ class AdvServiceModel extends \Business\AbstractModel{
}else{
$advs = array();
}
}
}*/
return $advs;
}
......
......@@ -270,7 +270,8 @@ class CouponServiceModel extends \Business\AbstractModel{
public function getStorePromotionCouponTitles($where){
$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']));
$couponTitles = $couponDao->getStorePromotionCouponList($where['storeId']);
//\Our\RedisHelper::cachedFunction(\Redis\Db13\CouponRedisModel::getInstance(), array(&$couponDao, 'getStorePromotionCouponList'),array($where['storeId']),\Our\ApiConst::oneHour,array($where['storeId']));
return $couponTitles?$couponTitles:array();
}
......@@ -376,22 +377,6 @@ class CouponServiceModel extends \Business\AbstractModel{
return $couponList;
}
/**
* 删除店铺优惠券缓存
* @param $storeId 店铺ID
* @param bool $couponId 指定优惠券ID
* @throws \Our\Exception
*/
public function deleteCouponCache($storeId,$couponId=false){
$couponDao = \DAO\Coupon\CouponModel::getInstance();
$memberCouponDao = \DAO\Coupon\MemberCouponModel::getInstance();
if($couponId){
\Our\RedisHelper::delCachedFunction(\Redis\Db13\MemberCouponRedisModel::getInstance(), array(&$memberCouponDao, 'getList'),array(),array($couponId));
}
\Our\RedisHelper::delCachedFunction(\Redis\Db13\CouponRedisModel::getInstance(), array(&$couponDao, 'getStorePromotionCouponList'),array(),array($storeId));
\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'];
......
......@@ -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 $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 $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 {
}*/
//$pBundlingList = $this->getGroupListForCart($blIds);
//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);
}
$goodsCommonIds = $cartListData['goodsCommonIds'];
......@@ -150,7 +152,9 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
if (!$pBundling) {
$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;
} else {
if($pBundling['bl_storage']<=\Our\ApiConst::zero){
......@@ -164,10 +168,12 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
}else{
$tempObj['blChangeFlag'] = \Our\ApiConst::one;
}
if($tempObj['goodsState'] != \Our\ApiConst::cartGoodsOffline){
$tempPrice = \Goods\GoodsUtil::getInstance()->getRealPrice($pBundling['blId'],null,null,\Our\ApiConst::addBundingToCart,\Our\DbNameConst::salveDBConnectName);
if($tempPrice){
$tempObj['goodsPrice'] = $tempPrice;
}
}
$tempObj['goodsImage'] = $pBundling['image'];
$tempObj['goodsList'] = \Our\Common::convertUnderline($pBundling['goodsList']);
......@@ -190,9 +196,11 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
}else{
$tempObj['goodsState'] = \Our\ApiConst::cartGoodsOffline;
}
if($tempObj['goodsState'] != \Our\ApiConst::cartGoodsOffline){
$price = \Goods\GoodsUtil::getInstance()->getRealPrice($tempCart['goods_id'],$memberId);
$tempObj['goodsPrice'] = $price?$price:$tempObj['goodsPrice'];
}
}
$tempObj['goodsAttr'] = $goodsDao->getFormatGoodsAttr($tempCart['goods_spec']);
$tempObj['goodsMid'] = $tempCart['goods_mid'];
array_push($storeCarts,$tempObj);
......@@ -303,12 +311,25 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
* 获取组合销售商品列表
* @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){
return false;
}
$field = $this->pBundingField;
if($isDel==\Our\ApiConst::one){
$field = $this->pBundingFieldWithDel;
}
$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);
return $newGroupList;
}
......@@ -536,7 +557,7 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
//unset($goods_temp['goods_image']);
//unset($goods_temp['bl_id']);
//$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;
}
if($tempGroup['bl_storage']>0&&floor($goods_temp['goodsStorage']/$goods_temp['num'])<$tempGroup['bl_storage']){
......@@ -583,7 +604,7 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
/*foreach($blIds as $val){
$group[]['blId']=$val;
}*/
$pBundlingList = $this->getPBundlingListByBlIds($blIds,$dbName,true);
$pBundlingList = $this->getPBundlingListByBlIds($blIds,$dbName,array(),true);
}
$goodsCommonIds = $cartListData['goodsCommonIds'];
$goodsIds = $cartListData['goodsIds'];
......
......@@ -317,7 +317,7 @@ class OrderServiceModel extends \Business\AbstractModel
}
}
if ($memberId) {
$orderDao->deleteOrderCache($memberId, $orderId, $order['store_id'],true);
$orderDao->deleteOrderCache($memberId, $orderId, $order['storeId'],true);
// $memberDao->fromOrderStateToOrderState($memberId,$order['order_state'],ApiConst::orderStateCancel);
}
}
......
......@@ -54,7 +54,7 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
$orderDao=\DAO\Order\OrderModel::getInstance();
$favoritesStoreDao=\DAO\FavoritesStoreModel::getInstance();
$orderGoodsDao=\DAO\Order\OrderGoodsModel::getInstance();
$goodsCount=\Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$orderGoodsDao, 'getOrderGoodsCountByStoreId'), array($storeId), ApiConst::one, array($storeId));
$goodsCount=\Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$orderGoodsDao, 'getOrderGoodsCountByStoreId'), array($storeId), ApiConst::tenDaySecond, array($storeId));
$condition['store_id'] = $storeId;
//获取店铺信息
$store = \Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$this->storeDao, 'getInfo'), array($condition), ApiConst::tenDaySecond, array($storeId));
......
......@@ -553,6 +553,9 @@ class AddressServiceModel extends \Business\AbstractModel {
if(!($address['citycode'])){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyCityCodeForSave);
}
if(intval($address['citycode'])<=0){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::wrongCityCode);
}
if(!($address['lng']&&$address['lat'])){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::chooseAddressFormMap);
}
......
......@@ -281,10 +281,10 @@ class MemberCenterServiceModel extends \Business\AbstractModel
//删除缓存
if(is_array($ids) && count($ids) <= 20){
foreach ($ids as $v){
\Our\RedisHelper::delCachedFunction(\Redis\Db4\FavoritesRedisModel::getInstance(),array(&$favoritesInstance, 'getOne'),array('*',array('goods_commonid'=>$v,'member_id'=>$memberId)),array($memberId));
\Our\RedisHelper::delCachedFunction(\Redis\Db4\FavoritesRedisModel::getInstance(),array(&$favoritesInstance, 'getOne'),array('*',array('member_id'=>$memberId,'goods_commonid'=>$v)),array($memberId));
}
}elseif (!is_array($ids)){
\Our\RedisHelper::delCachedFunction(\Redis\Db4\FavoritesRedisModel::getInstance(),array(&$favoritesInstance, 'getOne'),array('*',array('goods_commonid'=>$ids,'member_id'=>$memberId)),array($memberId));
\Our\RedisHelper::delCachedFunction(\Redis\Db4\FavoritesRedisModel::getInstance(),array(&$favoritesInstance, 'getOne'),array('*',array('member_id'=>$memberId,'goods_commonid'=>$ids)),array($memberId));
}else{
\Our\RedisHelper::delCachedFunction(\Redis\Db4\FavoritesRedisModel::getInstance(),array(&$favoritesInstance, 'getOne'),array(),array($memberId));
}
......
......@@ -152,9 +152,9 @@ class CouponModel extends \DAO\AbstractModel {
$field = $this->availStoreIndexField;
$where = ' and store_id ='.$storeId.' and type<>1';
$this->setDb($this->dbName);
$coupons = $this->getOnlineCouponList($where,$field);
//$coupons = $this->getOnlineCouponList($where,$field);
//$coupons = \Our\RedisHelper::cachedFunction(\Redis\Db13\CouponRedisModel::getInstance(), array(&$this, 'getOnlineCouponList'),array($where,$field),\Our\ApiConst::oneHour);
$coupons = \Our\RedisHelper::cachedFunction(\Redis\Db13\CouponRedisModel::getInstance(), array(&$this, 'getOnlineCouponList'),array($where,$field),\Our\ApiConst::oneHour,array($storeId));
//$coupons = $this->getOnlineCouponList($where,$field);
if(!$coupons){
......@@ -169,6 +169,9 @@ class CouponModel extends \DAO\AbstractModel {
$storeCouponGoodsClassDao = \DAO\GoodsClass\StoreCouponGoodsClassModel::getInstance();
$result = array();
foreach($coupons as $coupon){
if(!($coupon['start_time']<=TIMESTAMP&&$coupon['end_time']>TIMESTAMP)){
continue;
}
if($coupon['type']==\Our\ApiConst::goodsClassCoupon){ //指定品类优惠券,需要判断该优惠券对应分类店铺是否在经营
if($storeClassIds){
$gcIds = $storeCouponGoodsClassDao->getGoodsClassIdsByCouponId($coupon['id']);
......@@ -489,6 +492,27 @@ class CouponModel extends \DAO\AbstractModel {
}
}
/**
* 删除店铺优惠券缓存
* @param $storeId 店铺ID
* @param bool $couponId 指定优惠券ID
* @throws \Our\Exception
*/
public function deleteCouponCache($storeId,$couponId=false){
$couponService = \Business\Coupon\CouponServiceModel::getInstance();
$memberCouponDao = \DAO\Coupon\MemberCouponModel::getInstance();
if($couponId){
\Our\RedisHelper::delCachedFunction(\Redis\Db13\MemberCouponRedisModel::getInstance(), array(&$memberCouponDao, 'getList'),array(),array($couponId));
}
//\Our\RedisHelper::delCachedFunction(\Redis\Db13\CouponRedisModel::getInstance(), array(&$this, 'getStorePromotionCouponList'),array(),array($storeId));
\Our\RedisHelper::delCachedFunction(\Redis\Db13\CouponRedisModel::getInstance(), array(&$couponService, 'getStoreCouponsById'),array(),array($storeId));
\Our\RedisHelper::delCachedFunction(\Redis\Db13\CouponRedisModel::getInstance(), array(&$this, 'getOnlineCouponList'),array(),array($storeId));
return true;
}
public function getDb()
{
return $this->db;
......@@ -513,4 +537,5 @@ class CouponModel extends \DAO\AbstractModel {
}
......@@ -149,6 +149,7 @@ class DeliveryFormulaModel extends \DAO\AbstractModel {
break;
}
}
$expriseStartTime += $deliveryIntval*\Our\ApiConst::oneMinute;
if($expriseStartTime<$todayEndTime){
$expriseData = $this->getTomorrowFormulaList($expriseStartTime,$todayEndTime,$deliveryIntval*\Our\ApiConst::oneMinute,$minFee,$myCurrentStartTime);
if($expriseData){
......
......@@ -54,6 +54,7 @@ class OrderGoodsModel extends \DAO\AbstractModel {
*/
public function update($where, $data){
$this->setDb(DbNameConst::masterDBConnectName);
$data['gmt_update']=TIMESTAMP;
return $this->db->update($this->_tableName)->where($where)->rows($data)->execute();
}
......
......@@ -33,12 +33,28 @@ class PBundlingModel extends \DAO\AbstractModel {
// $where = array();
// $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);
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')->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){
if($image){
......
......@@ -367,6 +367,7 @@ class CodeConfigModel {
const emptyDistrictId = 140020;
const emptyAddressAndName = 140021;
const wrongAddressTagType = 140022;
const wrongCityCode = 140023;
//消息,推送等
const removeMessage=150001;
......@@ -599,6 +600,7 @@ class CodeConfigModel {
self::emptyDistrictId => '找不到对应区',
self::emptyAddressAndName => '地址和具体街道不能为空',
self::wrongAddressTagType => '地址标签传输错误',
self::wrongCityCode => '城市码格式错误',
self::emptyLatLng => '经纬度不能为空',
self::emptyCityCode => '高德地图城市编码不能为空',
......
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