Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
my-yaf-project
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenchuanwen
my-yaf-project
Commits
d384db68
Commit
d384db68
authored
Jan 04, 2019
by
liuyuzhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
下单从缓存处理
parent
f34b307f
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
300 additions
and
28 deletions
+300
-28
Goods.php
application/controllers/Goods.php
+1
-0
OrderConfirmUtil.php
application/library/Order/OrderConfirmUtil.php
+71
-5
NameConst.php
application/library/Our/NameConst.php
+4
-0
CartService.php
application/models/Business/Cart/CartService.php
+2
-2
CouponService.php
application/models/Business/Coupon/CouponService.php
+2
-0
GoodsCommonService.php
application/models/Business/Goods/GoodsCommonService.php
+12
-1
GroupSaleService.php
application/models/Business/Goods/GroupSaleService.php
+136
-1
MemberCoupon.php
application/models/DAO/Coupon/MemberCoupon.php
+28
-1
Goods.php
application/models/DAO/Goods.php
+1
-11
PBundling.php
application/models/DAO/PBundling.php
+31
-1
Abstract.php
application/models/Redis/Abstract.php
+6
-3
Abstract.php
application/models/Redis/Db4/Abstract.php
+2
-2
application.ini
conf/application.ini
+3
-0
index.php
public/index.php
+1
-1
No files found.
application/controllers/Goods.php
View file @
d384db68
...
...
@@ -28,6 +28,7 @@ class GoodsController extends \Our\Controller_AbstractIndex {
$this
->
goodsService
->
addBrowseRecord
(
$this
->
req
[
\Our\NameConst
::
data
],
$this
->
memberId
);
$this
->
success
(
array_merge
(
$goodsInfo
,
array
(
'store'
=>
$store
,
'recomndGoods'
=>
$recomndGoods
,
'evaluation'
=>
$evaluation
,
'groups'
=>
$groups
,
'share'
=>
$share
),
$coupons
));
}
/**
* 获取商品列表
*/
...
...
application/library/Order/OrderConfirmUtil.php
View file @
d384db68
...
...
@@ -76,7 +76,7 @@ class OrderConfirmUtil {
* @throws \Exception
*/
public
function
checkPostData
(
$data
,
$memberId
,
$currentAddress
){
$dbName
=
\Our\DbNameConst
::
master
DBConnectName
;
$dbName
=
\Our\DbNameConst
::
salve
DBConnectName
;
$this
->
memberId
=
$memberId
;
$this
->
member
=
\DAO\MemberModel
::
getInstance
()
->
getInfo
(
$this
->
memberId
);
$this
->
address
=
$this
->
checkCurrentAddress
(
$currentAddress
,
$this
->
memberId
);
...
...
@@ -340,7 +340,7 @@ class OrderConfirmUtil {
*/
public
function
checkDeliveryTypeAndPaywayNew
(
$storeCartData
){
$cartService
=
\Business\Cart\CartServiceModel
::
getInstance
();
$storeCartData
=
$cartService
->
getDeliveryTypeForCartNew
(
$this
->
address
,
$storeCartData
,
\Our\DbNameConst
::
master
DBConnectName
,
true
);
$storeCartData
=
$cartService
->
getDeliveryTypeForCartNew
(
$this
->
address
,
$storeCartData
,
\Our\DbNameConst
::
salve
DBConnectName
,
true
);
$currentTime
=
time
();
$todayTime
=
strtotime
(
date
(
'Y-m-d'
,
time
()));
$tomorrowTime
=
$todayTime
+
\Our\ApiConst
::
oneDaySecond
;
...
...
@@ -834,6 +834,7 @@ class OrderConfirmUtil {
$memberCouponDao
=
\DAO\Coupon\MemberCouponModel
::
getInstance
();
$couponService
=
\Business\Coupon\CouponServiceModel
::
getInstance
();
\Our\RedisHelper
::
delCachedFunction
(
\Redis\Db13\MemberCouponRedisModel
::
getInstance
(),
array
(
&
$memberCouponDao
,
'getList'
),
array
(),
array
(
$this
->
memberId
));
\Redis\Db13\MemberCouponRedisModel
::
getInstance
()
->
tableDel
(
\Our\NameConst
::
memberCounponListPrefix
.
$this
->
memberId
);
foreach
(
$this
->
storeIds
as
$tempStoreId
){
\Our\RedisHelper
::
delCachedFunction
(
\Redis\Db13\CouponRedisModel
::
getInstance
(),
array
(
&
$couponService
,
'getStoreCouponsById'
),
array
(),
array
(
$tempStoreId
.
"_"
.
$this
->
memberId
));
}
...
...
@@ -987,6 +988,7 @@ class OrderConfirmUtil {
}
/**
* 更新库存信息到数据库
* @param $goodsCommons
* @param $goodsList
* @param $blGoodsList
...
...
@@ -997,7 +999,7 @@ class OrderConfirmUtil {
* @throws \Error\OurExceptionModel
* @throws \Exception
*/
public
function
updateGoodsStorageToDB
AndCache
(
$goodsCommons
,
$goodsList
,
$blGoodsList
,
$goodsNewList
,
$op
=
\Our\ApiConst
::
minus
,
$updateSaleNumFlag
=
true
){
public
function
updateGoodsStorageToDB
(
$goodsCommons
,
$goodsList
,
$blGoodsList
,
$goodsNewList
,
$op
=
\Our\ApiConst
::
minus
,
$updateSaleNumFlag
=
true
){
if
(
$blGoodsList
){
$dbName
=
\Our\DbNameConst
::
masterDBConnectName
;
$pBundlingDao
=
\DAO\PBundlingModel
::
getInstance
(
$dbName
);
...
...
@@ -1018,7 +1020,24 @@ class OrderConfirmUtil {
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
goodsStorageToDBFailedForOrder
);
}
}
return
true
;
}
/**
* 更新库存信息到缓存
* @param $goodsCommons
* @param $goodsList
* @param $blGoodsList
* @param $goodsNewList
* @param int $op
* @param bool $updateSaleNumFlag
* @return bool
* @throws \Error\OurExceptionModel
* @throws \Exception
*/
public
function
updateGoodsStorageToCache
(
$goodsCommons
,
$goodsList
,
$blGoodsList
,
$goodsNewList
,
$op
=
\Our\ApiConst
::
minus
,
$updateSaleNumFlag
=
true
){
$pBundlingDao
=
\DAO\PBundlingModel
::
getInstance
();
$goodsDao
=
\DAO\GoodsModel
::
getInstance
();
if
(
$blGoodsList
){
foreach
(
$blGoodsList
as
$key
=>
$blGoods
){
$pBundlingCacheResult
=
$pBundlingDao
->
opBlGoodsStorage
(
$key
,
$blGoods
[
'blStorage'
]);
//组合销售库存删减
...
...
@@ -1035,6 +1054,54 @@ class OrderConfirmUtil {
}
return
true
;
}
/**
* @param $goodsCommons
* @param $goodsList
* @param $blGoodsList
* @param $goodsNewList
* @param int $op
* @param bool $updateSaleNumFlag
* @return bool
* @throws \Error\OurExceptionModel
* @throws \Exception
*/
public
function
updateGoodsStorageToDBAndCache
(
$goodsCommons
,
$goodsList
,
$blGoodsList
,
$goodsNewList
,
$op
=
\Our\ApiConst
::
minus
,
$updateSaleNumFlag
=
true
){
if
(
$blGoodsList
){
$dbName
=
\Our\DbNameConst
::
masterDBConnectName
;
$pBundlingDao
=
\DAO\PBundlingModel
::
getInstance
(
$dbName
);
$pBundlingResult
=
$pBundlingDao
->
updateBlStorage
(
$blGoodsList
);
if
(
!
$pBundlingResult
){
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
blGoodsStorageToDBFailedForOrder
);
}
}
if
(
$goodsCommons
&&
$goodsList
){
$dbName
=
\Our\DbNameConst
::
masterDBConnectName
;
$goodsDao
=
\DAO\GoodsModel
::
getInstance
(
$dbName
);
$goodsCommonDao
=
\DAO\GoodsCommonModel
::
getInstance
(
$dbName
);
$resultGoodsCommon
=
$goodsCommonDao
->
updateGoodsStorage
(
$goodsCommons
,
$op
,
$updateSaleNumFlag
);
$resultGoods
=
$goodsDao
->
updateGoodsStorage
(
$goodsNewList
,
$op
);
if
(
!
(
$resultGoodsCommon
&&
$resultGoods
)){
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
goodsStorageToDBFailedForOrder
);
}
}
if
(
$blGoodsList
){
foreach
(
$blGoodsList
as
$key
=>
$blGoods
){
$pBundlingCacheResult
=
$pBundlingDao
->
opBlGoodsStorage
(
$key
,
$blGoods
[
'blStorage'
],
$op
);
//组合销售库存删减
if
(
$pBundlingCacheResult
===
false
){
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
blGoodsStorageToCacheFailedForOrder
);
}
}
}
if
(
$goodsCommons
&&
$goodsList
){
$resultGoodsCache
=
$goodsDao
->
opOnlineStorageGoodsByGoodsCommonIds
(
$goodsList
,
$op
,
$updateSaleNumFlag
);
if
(
!
$resultGoodsCache
){
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
goodsStorageToCacheFailedForOrder
);
}
}
return
true
;
}
/**
* 生成支付单编号(两位随机 + 从2000-01-01 00:00:00 到现在的秒数+微秒+会员ID%1000),该值会传给第三方支付接口
* 长度 =2位 + 10位 + 3位 + 3位 = 18位
...
...
@@ -1079,8 +1146,7 @@ class OrderConfirmUtil {
//第一步:获取购物车可展示优惠券信息
$memberCouponDao
=
\DAO\Coupon\MemberCouponModel
::
getInstance
(
\Our\DbNameConst
::
masterDBConnectName
);
$whereSql
=
' coupon_state ='
.
\Our\ApiConst
::
couponUnused
.
' and member_id ='
.
$memberId
.
' and out_time > '
.
time
();
$memberCouponArray
=
$memberCouponDao
->
getList
(
$whereSql
,
'coupon_id'
);
$memberCouponArray
=
$memberCouponDao
->
getMemberCouponByMemberIdWithOuttime
(
$memberId
);
if
(
!
$memberCouponArray
){
$storeCartData
[
'couponList'
]
=
array
();
return
$storeCartData
;
...
...
application/library/Our/NameConst.php
View file @
d384db68
...
...
@@ -68,6 +68,8 @@ class NameConst {
const
nearbyStoreGoodsPrefix
=
'nearbyStoreGoods_'
;
const
memberCounponListPrefix
=
'unusedMemberCouponList_'
;
const
cityCode
=
'cityCode'
;
const
lat
=
'lat'
;
const
lng
=
'lng'
;
...
...
@@ -132,6 +134,8 @@ class NameConst {
const
onlineStorageBlGoodsPrefix
=
'onlineStorageBlGoods'
;
//组合销售库存前缀
const
onlineStorageBlGoodsOriginPrefix
=
'onlineStorageBlGoodsOrigin'
;
//组合销售本身库存前缀
const
storeCoverPrefix
=
'storeCover_'
;
const
storeMiddleAdvsPrefix
=
'storeMiddleAdvs_'
;
...
...
application/models/Business/Cart/CartService.php
View file @
d384db68
...
...
@@ -843,12 +843,12 @@ class CartServiceModel extends \Business\AbstractModel{
}
//第一步:获取购物车可展示优惠券信息
$memberCouponDao
=
\DAO\Coupon\MemberCouponModel
::
getInstance
();
$whereSql
=
' coupon_state ='
.
\Our\ApiConst
::
couponUnused
.
' and member_id ='
.
$memberId
.
' and out_time > '
.
time
();
$memberCouponArray
=
$memberCouponDao
->
getList
(
$whereSql
,
'coupon_id'
);
$memberCouponArray
=
$memberCouponDao
->
getMemberCouponByMemberIdWithOuttime
(
$memberId
);
if
(
!
$memberCouponArray
){
$storeCartData
[
'couponList'
]
=
array
();
return
$storeCartData
;
}
$couponStoreIds
=
$storeCartData
[
'storeIds'
];
$couponStoreIds
[]
=
\Our\ApiConst
::
zero
;
$couponIds
=
array_column
(
$memberCouponArray
,
'coupon_id'
);
...
...
application/models/Business/Coupon/CouponService.php
View file @
d384db68
...
...
@@ -185,6 +185,7 @@ class CouponServiceModel extends \Business\AbstractModel{
$couponDao
->
db
->
doCommit
();
//\Our\RedisHelper::delCachedFunction(\Redis\Db13\MemberCouponRedisModel::getInstance(), array(&$memberCouponDao, 'getList'),array(),array($where['couponId']));
\Our\RedisHelper
::
delCachedFunction
(
\Redis\Db13\MemberCouponRedisModel
::
getInstance
(),
array
(
&
$memberCouponDao
,
'getList'
),
array
(),
array
(
$memberId
));
\Redis\Db13\MemberCouponRedisModel
::
getInstance
()
->
tableDel
(
\Our\NameConst
::
memberCounponListPrefix
.
$memberId
);
\Our\RedisHelper
::
delCachedFunction
(
\Redis\Db13\CouponRedisModel
::
getInstance
(),
array
(
&
$this
,
'getStoreCouponsById'
),
array
(),
array
(
$coupon
[
'store_id'
]
.
"_"
.
$memberId
));
return
true
;
}
...
...
@@ -238,6 +239,7 @@ class CouponServiceModel extends \Business\AbstractModel{
}
}
\Our\RedisHelper
::
delCachedFunction
(
\Redis\Db13\MemberCouponRedisModel
::
getInstance
(),
array
(
&
$memberCouponDao
,
'getList'
),
array
(),
array
(
$memberId
));
\Redis\Db13\MemberCouponRedisModel
::
getInstance
()
->
tableDel
(
\Our\NameConst
::
memberCounponListPrefix
.
$memberId
);
$couponDao
->
db
->
doCommit
();
return
true
;
}
...
...
application/models/Business/Goods/GoodsCommonService.php
View file @
d384db68
...
...
@@ -585,7 +585,18 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
$activities
=
\DAO\SaleMemberModel
::
getInstance
()
->
isJoinStore
(
$commonInfo
[
'store_id'
],
$memberId
);
//商品表
$goodsInstance
=
\DAO\GoodsModel
::
getInstance
();
$goods
=
\Our\RedisHelper
::
cachedFunction
(
\Redis\Db4\GoodsRedisModel
::
getInstance
(),
array
(
&
$goodsInstance
,
'getListAndSetStorage'
),
array
(
$goodsCommonId
,
'goods_id,goods_price,goods_marketprice,goods_image,goods_storage,goods_spec,goods_state,goods_verify,is_del'
),
\Our\ApiConst
::
oneDaySecond
,
array
(
$goodsCommonId
));
$goods
=
\Our\RedisHelper
::
cachedFunction
(
\Redis\Db4\GoodsRedisModel
::
getInstance
(),
array
(
&
$goodsInstance
,
'getListAndSetStorage'
),
array
(
$goodsCommonId
,
'goods_id,goods_price,goods_marketprice,goods_image,goods_storage,goods_spec,goods_state,goods_verify,is_transport,transport_id,snapshot_id,is_del'
),
\Our\ApiConst
::
oneDaySecond
,
array
(
$goodsCommonId
));
$resetGoods
=
array
();
foreach
(
$goods
as
$tempGoods
){
unset
(
$tempGoods
[
'goods_state'
]);
unset
(
$tempGoods
[
'goods_verify'
]);
unset
(
$tempGoods
[
'is_del'
]);
unset
(
$tempGoods
[
'is_transport'
]);
unset
(
$tempGoods
[
'transport_id'
]);
unset
(
$tempGoods
[
'snapshot_id'
]);
array_push
(
$resetGoods
,
$tempGoods
);
}
$goods
=
$resetGoods
;
//商品图片表
$goodsImagesInstance
=
\DAO\GoodsImagesModel
::
getInstance
();
$image
=
\Our\RedisHelper
::
cachedFunction
(
\Redis\Db4\GoodsImagesRedisModel
::
getInstance
(),
array
(
&
$goodsImagesInstance
,
'getListByCommonId'
),
array
(
$goodsCommonId
,
'attr_name,attr_value,goods_image'
),
\Our\ApiConst
::
oneDaySecond
,
array
(
$goodsCommonId
));
...
...
application/models/Business/Goods/GroupSaleService.php
View file @
d384db68
...
...
@@ -577,6 +577,7 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
}
else
{
$tempGroup
[
'goodsCountFlag'
]
=
false
;
}
$tempGroup
[
'bl_origin_storage'
]
=
$tempGroup
[
'bl_storage'
]
?
$tempGroup
[
'bl_storage'
]
:
\Our\ApiConst
::
zero
;
//组合销售本身库存
foreach
(
$pBundlingGoods
as
$goods
){
if
(
key_exists
(
$goods
[
'goods_id'
],
$goodsArray
)){
$goods_temp
=
array_merge
(
$goods
,
$goodsArray
[
$goods
[
'goods_id'
]]);
...
...
@@ -603,6 +604,7 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
}
$goodsPrefix
.=
\Our\NameConst
::
blGoods
.
$goods_temp
[
'goodsCommonId'
];
}
$bundlingRedis
->
tableHSet
(
\Our\NameConst
::
onlineStorageBlGoodsPrefix
,
$bl_id
,
$tempGroup
[
'bl_storage'
],
\Our\ApiConst
::
oneDaySecond
);
}
$tempGroup
[
'sumPrice'
]
=
$blSumPrice
;
$bundlingRedis
->
tableCacheSet
(
'gid_'
.
$bl_id
.
$goodsPrefix
,
serialize
(
$tempGroup
),
\Our\ApiConst
::
oneDaySecond
);
...
...
@@ -614,6 +616,139 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
}
/**
* 获取单个组合销售的库存
* @param $blId
* @return int
*/
public
function
getBlGoodsStorage
(
$blId
){
$storages
=
$this
->
getBlGoodsStorageByBlIds
(
array
(
$blId
));
if
(
$storages
){
return
$storages
[
$blId
];
}
return
\Our\ApiConst
::
zero
;
}
/**
* 根据组合销售主键获取组合销售的库存
* @param $blIds
* @return array
*/
public
function
getBlGoodsStorageByBlIds
(
$blIds
){
$pBundlingRedis
=
\Redis\Db4\PBundlingRedisModel
::
getInstance
();
$storeages
=
array
();
$noCacheBlIds
=
array
();
foreach
(
$blIds
as
$blId
){
if
(
$pBundlingRedis
->
tableHExists
(
\Our\NameConst
::
onlineStorageBlGoodsPrefix
,
$blId
)){
$storage
=
$pBundlingRedis
->
tableHGet
(
\Our\NameConst
::
onlineStorageBlGoodsPrefix
,
$blId
);
$storeages
[
$blId
]
=
$storage
?
$storage
:
\Our\ApiConst
::
zero
;
}
else
{
array_push
(
$noCacheBlIds
,
$blId
);
}
}
if
(
$noCacheBlIds
){
$noCacheStoreages
=
$this
->
getBlGoodsStorageByBlIdsFromDb
(
$blIds
);
$storeages
=
array_merge
(
$noCacheStoreages
,
$storeages
);
}
return
$storeages
;
}
/**
* 通过组合销售主键从数据库查找对应组合销售的库存
* @param $blIds
* @return array
* @throws \Our\Exception
*/
public
function
getBlGoodsStorageByBlIdsFromDb
(
$blIds
){
$pbundlingModel
=
\DAO\PBundlingModel
::
getInstance
();
$groupList
=
\Our\RedisHelper
::
cachedFunction
(
\Redis\Db4\PBundlingRedisModel
::
getInstance
(),
array
(
&
$pbundlingModel
,
'getList'
),
array
(
$this
->
pBundingField
,
array
(
'bl_id'
=>
$blIds
),
array
(
\Our\ApiConst
::
zero
,
count
(
$blIds
))),
\Our\ApiConst
::
oneDaySecond
);
$storages
=
$this
->
getBlGoodsStorageByGroupList
(
$groupList
);
return
$storages
;
}
/**
* 根据组合销售的列表查找库存
* @param $groupList
* @return array|bool
*/
public
function
getBlGoodsStorageByGroupList
(
$groupList
){
if
(
!
$groupList
){
return
false
;
}
$blIds
=
array_column
(
$groupList
,
'blId'
);
$pBundlingArray
=
[];
foreach
(
$groupList
as
$v
){
$pBundlingArray
[
$v
[
'blId'
]]
=
$v
;
}
$pBundlingGoodsDao
=
\DAO\PBundlingGoodsModel
::
getInstance
();
$goodsDao
=
\DAO\GoodsModel
::
getInstance
();
$bundingGoodsWhere
[
'bl_id'
]
=
array
(
'in'
,
$blIds
);
$bundlingGoodsList
=
$pBundlingGoodsDao
->
getList
(
$this
->
pBundingGoodsField
,
$bundingGoodsWhere
);
$group
=
array
();
if
(
$bundlingGoodsList
){
$blGoodsIds
=
array
();
$goodsIds
=
array_column
(
$bundlingGoodsList
,
'goods_id'
);
$goodsList
=
$goodsDao
->
getList
(
'goods_id in ('
.
implode
(
','
,
$goodsIds
)
.
')'
,
$this
->
pBundingGoodsDetailField
);
if
(
$goodsList
){
$bundlingRedis
=
\Redis\Db4\PBundlingRedisModel
::
getInstance
();
$pBundlingGoodsArray
=
array
();
foreach
(
$bundlingGoodsList
as
$v
){
$pBundlingGoodsArray
[
$v
[
'bl_id'
]][
$v
[
'goods_id'
]]
=
$v
;
$blGoodsIds
[
$v
[
'bl_id'
]][]
=
$v
[
'goods_id'
];
}
$goodsArray
=
[];
foreach
(
$goodsList
as
$v
){
$goodsArray
[
$v
[
'goods_id'
]]
=
$v
;
}
foreach
(
$pBundlingGoodsArray
as
$bl_id
=>
$pBundlingGoods
){
$goodsPrefix
=
''
;
$blSumPrice
=
\Our\ApiConst
::
zero
;
if
(
$pBundlingGoods
&&
is_array
(
$pBundlingGoods
)){
$tempGroup
=
$pBundlingArray
[
$bl_id
];
foreach
(
$pBundlingGoods
as
$goods
){
if
(
key_exists
(
$goods
[
'goods_id'
],
$goodsArray
)){
$goods_temp
=
array_merge
(
$goods
,
$goodsArray
[
$goods
[
'goods_id'
]]);
if
(
$tempGroup
[
'bl_storage'
]
>
0
&&
floor
(
$goods_temp
[
'goodsStorage'
]
/
$goods_temp
[
'num'
])
<
$tempGroup
[
'bl_storage'
]){
$tempGroup
[
'bl_storage'
]
=
floor
(
$goods_temp
[
'goodsStorage'
]
/
$goods_temp
[
'num'
]);
}
}
}
$bundlingRedis
->
tableHSet
(
\Our\NameConst
::
onlineStorageBlGoodsPrefix
,
$bl_id
,
$tempGroup
[
'bl_storage'
],
\Our\ApiConst
::
oneDaySecond
);
$group
[
$bl_id
]
=
$tempGroup
[
'bl_storage'
];
}
}
}
}
return
$group
;
}
/**
* 获取普通商品对应的缓存商品信息
*/
public
function
getOnlineGoodsCommonInfoForCart
(
$goodsCommonIds
){
$goodsRedis
=
\Redis\Db4\GoodsRedisModel
::
getInstance
();
$goodsModel
=
\DAO\GoodsModel
::
getInstance
();
foreach
(
$goodsCommonIds
as
$goodsCommonId
){
$goodsList
=
\Our\RedisHelper
::
cachedFunction
(
\Redis\Db4\GoodsRedisModel
::
getInstance
(),
array
(
&
$goodsModel
,
'getListAndSetStorage'
),
array
(
$goodsCommonId
,
'goods_id,goods_price,goods_marketprice,goods_image,goods_storage,goods_spec,goods_state,goods_verify,is_transport,transport_id,snapshot_id,is_del'
),
\Our\ApiConst
::
oneDaySecond
,
array
(
$goodsCommonId
));
$returnData
[
$goodsCommonId
]
=
$goodsList
[
0
];
$onlineStorageGoodsKey
=
\Our\NameConst
::
onlineStorageGoodsPrefix
.
$goodsCommonId
;
$onlineStorageGoods
=
$goodsRedis
->
tableHGAll
(
$onlineStorageGoodsKey
);
if
(
$onlineStorageGoods
){
$storageList
=
array
();
foreach
(
$onlineStorageGoods
as
$key
=>&
$value
){
$value
=
unserialize
(
$value
);
$returnData
[
$goodsCommonId
][
$key
]
=
$value
;
}
}
}
return
$returnData
;
}
/**
* 获取订单确认需要的购物车商品
* @param $storeCartList
...
...
@@ -640,7 +775,7 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
$goodsIds
=
$cartListData
[
'goodsIds'
];
$goodsCommonStorages
=
array
();
if
(
$goodsCommonIds
){
$goodsCommonStorages
=
$
goodsDao
->
getOnlineStorageGoodsByGoodsCommonIds
(
$goodsCommonIds
,
true
);
$goodsCommonStorages
=
$
this
->
getOnlineGoodsCommonInfoForCart
(
$goodsCommonIds
);
}
$storeCartList
=
$cartListData
[
'cartList'
];
if
(
!
$storeCartList
){
...
...
application/models/DAO/Coupon/MemberCoupon.php
View file @
d384db68
...
...
@@ -41,7 +41,6 @@ class MemberCouponModel extends \DAO\AbstractModel{
*/
public
function
getListByMemberId
(
$memberId
,
$couponIds
){
$whereSql
=
' member_id = '
.
$memberId
.
' and coupon_id in ('
.
implode
(
','
,
$couponIds
)
.
')'
;
$result
=
$this
->
getList
(
$whereSql
);
return
$result
;
}
...
...
@@ -59,6 +58,34 @@ class MemberCouponModel extends \DAO\AbstractModel{
return
$memberCoupons
;
}
/**
* 获取当前用户未领取的有效优惠券
* @param $where
* @param $memberId
* @return array
*/
public
function
getMemberCouponByMemberIdWithOuttime
(
$memberId
){
$memberCouponRedisModel
=
\Redis\Db13\MemberCouponRedisModel
::
getInstance
();
$memberCoupons
=
$memberCouponRedisModel
->
tableCacheGet
(
\Our\NameConst
::
memberCounponListPrefix
.
$memberId
);
if
(
$memberCoupons
){
$newMemberCouponArray
=
array
();
foreach
(
$memberCoupons
as
$tempMemberCoupon
){
if
(
$tempMemberCoupon
[
'out_time'
]
>=
TIMESTAMP
){
$newMemberCouponArray
[]
=
$tempMemberCoupon
;
}
}
return
$newMemberCouponArray
;
}
$where
=
' coupon_state ='
.
\Our\ApiConst
::
couponUnused
.
' and member_id ='
.
$memberId
;
$where
.=
' and out_time > '
.
TIMESTAMP
;
$field
=
'coupon_id,add_time,out_time'
;
$memberCoupons
=
$this
->
getList
(
$where
,
$field
);
if
(
$memberCoupons
){
$memberCouponRedisModel
->
tableCacheSet
(
\Our\NameConst
::
memberCounponListPrefix
.
$memberId
,
$memberCoupons
,
\Our\ApiConst
::
oneDaySecond
);
}
return
$memberCoupons
;
}
public
function
getValidMemberCoupon
(
$where
,
$memberId
){
if
(
!
$memberId
){
$this
->
errorCode
=
\Error\CodeConfigModel
::
emptyMemberCouponMemberId
;
...
...
application/models/DAO/Goods.php
View file @
d384db68
...
...
@@ -265,7 +265,6 @@ class GoodsModel extends \DAO\AbstractModel {
}
/**
* 根据商品CommonId获取库存信息
* @param $goodsCommonIds
...
...
@@ -293,7 +292,7 @@ class GoodsModel extends \DAO\AbstractModel {
$sql
=
\Our\Common
::
format
(
' goods_commonid in ({0})'
,
implode
(
','
,
$noRedisGoodsCommonIds
));
$field
=
'goods_commonid,goods_id,goods_storage,goods_state,goods_verify,is_del'
;
}
if
(
$sql
&&
$field
){
if
(
isset
(
$sql
)
&&
isset
(
$field
)
){
$goodsArray
=
$this
->
getList
(
$sql
,
$field
);
$goodsCommonList
=
array
();
$goodsList
=
array
();
...
...
@@ -359,18 +358,9 @@ class GoodsModel extends \DAO\AbstractModel {
if
(
$goods
[
'goods_state'
]
==
\Our\ApiConst
::
onlineGoodsState
&&
$goods
[
'goods_verify'
]
==
\Our\ApiConst
::
onlineGoodsVerify
&&
$goods
[
'is_del'
]
==
\Our\ApiConst
::
onlineGoodsDel
){
$onlineFlag
=
\Our\ApiConst
::
one
;
}
unset
(
$goodsList
[
$key
][
'goods_state'
]);
unset
(
$goodsList
[
$key
][
'goods_verify'
]);
unset
(
$goodsList
[
$key
][
'is_del'
]);
$data
[
$goods
[
'goods_id'
]]
=
serialize
(
array
(
'onlineFlag'
=>
$onlineFlag
,
'goodsStorage'
=>
$goods
[
'goods_storage'
]));
}
$goodsRedis
->
tableHMSet
(
$onlineStorageGoodsKey
,
$data
,
\Our\ApiConst
::
tenDaySecond
);
}
else
{
foreach
(
$goodsList
as
$key
=>
$goods
){
unset
(
$goodsList
[
$key
][
'goods_state'
]);
unset
(
$goodsList
[
$key
][
'goods_verify'
]);
unset
(
$goodsList
[
$key
][
'is_del'
]);
}
}
}
...
...
application/models/DAO/PBundling.php
View file @
d384db68
...
...
@@ -3,6 +3,8 @@
namespace
DAO
;
use
Error\CodeConfigModel
;
class
PBundlingModel
extends
\DAO\AbstractModel
{
...
...
@@ -92,6 +94,8 @@ class PBundlingModel extends \DAO\AbstractModel {
$pBundling
=
$this
->
findById
(
$blId
,
$field
);
if
(
$pBundling
){
$storage
=
$pBundling
[
'bl_storage'
];
$bundingGoodsWhere
[
'bl_id'
]
=
$blId
;
$bundlingGoodsList
=
\DAO\PBundlingGoodsModel
::
getInstance
()
->
getList
(
$this
->
pBundingGoodsField
,
$bundingGoodsWhere
);
$pBundlingRedis
->
tableHSet
(
\Our\NameConst
::
onlineStorageBlGoodsPrefix
,
$blId
,
$pBundling
[
'bl_storage'
],
\Our\ApiConst
::
oneDaySecond
);
}
else
{
$storage
=
\Our\ApiConst
::
zero
;
...
...
@@ -160,7 +164,33 @@ class PBundlingModel extends \DAO\AbstractModel {
public
function
getPBundlingCacheByBlId
(
$blId
){
$pBundlingDao
=
\Redis\Db4\PBundlingRedisModel
::
getInstance
();
return
$pBundlingDao
->
getByKeys
(
'gid_'
.
$blId
);
$result
=
$pBundlingDao
->
getByKeys
(
'gid_'
.
$blId
);
if
(
$result
){
return
$result
[
'result'
];
}
return
false
;
}
public
function
updatePBundlingStorageCacheByBlId
(
$blId
,
$blStorage
,
$op
=
\Our\ApiConst
::
minus
){
$pBundlingRedisDao
=
\Redis\Db4\PBundlingRedisModel
::
getInstance
();
$result
=
$pBundlingRedisDao
->
getByKeys
(
'gid_'
.
$blId
);
if
(
$result
){
$pBundling
=
$result
[
'result'
];
$key
=
$result
[
'key'
];
if
(
$pBundling
[
'bl_storage'
])
if
(
$op
==
\Our\ApiConst
::
minus
){
$pBundling
[
'bl_storage'
]
=
$pBundling
[
'bl_storage'
]
-
$blStorage
;
if
(
$pBundling
[
'bl_storage'
]
-
$blStorage
<
\Our\ApiConst
::
zero
){
\Error\ErrorModel
::
throwException
(
\Our\CodeConfigModel
::
pBundlingNoStorageForOrder
);
}
$pBundling
[
'bl_origin_storage'
]
=
$pBundling
[
'bl_origin_storage'
]
-
$blStorage
;
}
else
if
(
$op
==
\Our\ApiConst
::
plus
){
$pBundling
[
'bl_storage'
]
=
$pBundling
[
'bl_storage'
]
+
$blStorage
;
$pBundling
[
'bl_origin_storage'
]
=
$pBundling
[
'bl_origin_storage'
]
+
$blStorage
;
}
return
$pBundlingRedisDao
->
setNoPrefix
(
$key
,
$pBundling
,
\Our\ApiConst
::
oneDaySecond
);
}
return
false
;
}
public
function
deletePBundlingByBlId
(
$blId
){
...
...
application/models/Redis/Abstract.php
View file @
d384db68
...
...
@@ -89,9 +89,8 @@ class AbstractModel {
* @return
*/
public
function
del
(
$key
)
{
$keyNEw
=
$this
->
_addPrefix
(
$key
);
var_dump
(
$keyNEw
);
return
$this
->
getRedis
()
->
del
(
$keyNEw
);
$keyNew
=
$this
->
_addPrefix
(
$key
);
return
$this
->
getRedis
()
->
del
(
$keyNew
);
}
public
function
delAll
(
$data
){
return
$this
->
getRedis
()
->
del
(
$data
);
...
...
@@ -148,6 +147,10 @@ class AbstractModel {
public
function
getNoPrefix
(
$key
){
return
$this
->
getRedis
()
->
get
(
$key
);
}
public
function
setNoPrefix
(
$key
,
$value
,
$expire
=
0
){
return
$this
->
getRedis
()
->
set
(
$key
,
$value
,
$expire
);
}
/**
* redis自增1
*
...
...
application/models/Redis/Db4/Abstract.php
100755 → 100644
View file @
d384db68
...
...
@@ -39,9 +39,9 @@ class AbstractModel extends \Redis\AbstractModel {
$str
=
$str
[
0
];
$result
=
$this
->
getNoPrefix
(
$str
);
if
(
$this
->
is_serialized
(
$result
)){
return
unserialize
(
$result
);
$result
=
unserialize
(
$result
);
}
return
$result
;
return
array
(
'key'
=>
$str
,
'result'
=>
$result
)
;
}
else
{
return
false
;
}
...
...
conf/application.ini
View file @
d384db68
...
...
@@ -400,6 +400,7 @@ elastic.master.port="9200"
elastic.master.scheme
=
"http"
;
[lyztest : common]
; 数据库配置
resources.database.params.driver
=
"pdo_mysql"
resources.database.params.hostname
=
"127.0.0.1"
...
...
@@ -420,6 +421,8 @@ resources.database.slave.params.password = "123456"
resources.database.slave.params.charset
=
"UTF8"
resources.database.slave.params.driver_options.1002
=
"SET NAMES utf8"
password.key
=
'~!@#$`1234qwertasdfgzxcvb'
redis.database.params.host
=
"127.0.0.1"
...
...
public/index.php
View file @
d384db68
...
...
@@ -7,7 +7,7 @@ define("APP_ENV",ini_get('yaf.environ'));
if
(
APP_ENV
==
'develop'
){
error_reporting
(
E_ALL
);
}
if
(
APP_ENV
==
'test'
||
APP_ENV
==
'pre'
||
APP_ENV
==
'ccwdevelop'
||
APP_ENV
==
'product'
||
APP_ENV
==
'productone'
){
if
(
APP_ENV
==
'test'
||
APP_ENV
==
'pre'
||
APP_ENV
==
'ccwdevelop'
||
APP_ENV
==
'product'
||
APP_ENV
==
'productone'
||
APP_ENV
==
'lyztest'
){
if
(
isset
(
$_POST
[
'data'
][
'debug'
])
&&!
empty
(
$_POST
[
'data'
][
'debug'
])){
// define("DEBUG",1);
error_reporting
(
E_ALL
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment