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
81353b65
Commit
81353b65
authored
Nov 07, 2018
by
zhz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
store
parent
6f3daacc
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
116 additions
and
60 deletions
+116
-60
Store.php
application/controllers/Store.php
+15
-3
StoreService.php
application/models/Business/Store/StoreService.php
+5
-0
MemberCenterService.php
application/models/Business/User/MemberCenterService.php
+52
-53
MemberService.php
application/models/Business/User/MemberService.php
+4
-0
FavoritesStore.php
application/models/DAO/FavoritesStore.php
+36
-4
StoreScoreStatistics.php
application/models/DAO/StoreScoreStatistics.php
+4
-0
No files found.
application/controllers/Store.php
View file @
81353b65
...
...
@@ -13,9 +13,21 @@ class StoreController extends \Our\Controller_AbstractIndex {
* 获取店铺首页头部
*/
public
function
getStoreInfoAction
(){
$address
=
\Business\User\AddressServiceModel
::
getInstance
()
->
getMyAddress
(
$this
->
req
[
\Our\NameConst
::
data
],
$this
->
memberId
,
false
);
$storeInfo
=
$this
->
storeService
->
getStoreInfo
(
$this
->
req
[
\Our\NameConst
::
data
],
$this
->
memberId
,
$address
);
$storeInfo
[
'share'
]
=
\Business\Common\CommonServiceModel
::
getInstance
()
->
getShareInfo
(
\Our\ApiConst
::
shareStore
,
$this
->
req
[
\Our\NameConst
::
data
][
'storeId'
]);
//获取地址相关信息
$data
=
$this
->
req
[
\Our\NameConst
::
data
];
$addressService
=
\Business\User\AddressServiceModel
::
getInstance
();
$memberId
=
$this
->
sess
->
get
(
'member_id'
);
$currentAddress
=
$addressService
->
setAddress
(
$data
,
$memberId
);
if
(
!
isset
(
$currentAddress
[
'addresses'
])){
$currentAddress
[
'addresses'
]
=
array
();
}
//$returnData['currentAddress'] = $currentAddress;
$address
=
$addressService
->
getMyAddress
(
$data
,
$this
->
memberId
,
false
);
$storeInfo
=
$this
->
storeService
->
getStoreInfo
(
$data
,
$this
->
memberId
,
$address
);
$storeInfo
[
'share'
]
=
\Business\Common\CommonServiceModel
::
getInstance
()
->
getShareInfo
(
\Our\ApiConst
::
shareStore
,
$data
[
'storeId'
]);
$storeInfo
[
'currentAddress'
]
=
$currentAddress
;
$this
->
success
(
$storeInfo
);
}
/**
...
...
application/models/Business/Store/StoreService.php
View file @
81353b65
...
...
@@ -48,7 +48,12 @@ class StoreServiceModel extends \Business\AbstractModel{
$storeMember
[
'fav_type'
]
=
\Our\ApiConst
::
one
;
$storeMembers
[]
=
$storeMember
;
$favoritesStoreDao
=
\DAO\FavoritesStoreModel
::
getInstance
();
$one
=
$favoritesStoreDao
->
selectList
(
array
(
'store_id'
=>
$storeId
,
'member_id'
=>
$memberId
,
'fav_type'
=>
0
),
'store_id'
);
$one
&&
$storeIds
=
array
(
$one
[
'store_id'
]);
$result
=
$favoritesStoreDao
->
insertAll
(
$storeMembers
);
if
(
$result
)
{
$favoritesStoreDao
->
updateStoreCollecitonsCache
(
$storeIds
,
$memberId
,
2
);
}
$favoritesDao
=
\DAO\FavoritesStoreModel
::
getInstance
();
\Our\RedisHelper
::
delCachedFunction
(
\Redis\Db6\FavoritesStoreRedisModel
::
getInstance
(),
array
(
&
$favoritesDao
,
'getOne'
),
array
(),
array
(
$memberId
));
}
else
{
...
...
application/models/Business/User/MemberCenterService.php
View file @
81353b65
This diff is collapsed.
Click to expand it.
application/models/Business/User/MemberService.php
View file @
81353b65
...
...
@@ -356,11 +356,15 @@ class MemberServiceModel extends \Business\AbstractModel
/*$storeMemberDao = \DAO\StoreMemberModel::getInstance(\Our\DbNameConst::masterDBConnectName);
$result = $storeMemberDao->addBatch($storeMember);*/
$favoritesStoreDao
=
\DAO\FavoritesStoreModel
::
getInstance
();
$storeIds
=
array_column
(
$scan_store_ids
,
'store_id'
);
$list
=
$favoritesStoreDao
->
selectList
(
array
(
'store_id'
=>
array
(
'in'
,
$storeIds
),
'member_id'
=>
$memberId
,
'fav_type'
=>
0
),
'store_id'
);
$list
&&
$storeIds
=
array_column
(
$list
,
'store_id'
);
$result
=
$favoritesStoreDao
->
insertAll
(
$storeMembers
);
if
(
!
$result
){
\Our\Log
::
getInstance
()
->
write
(
json_encode
(
$storeMembers
)
.
'扫码数据写入失败'
);
return
false
;
}
$favoritesStoreDao
->
updateStoreCollecitonsCache
(
$storeIds
,
$memberId
,
2
);
$favoritesDao
=
\DAO\FavoritesStoreModel
::
getInstance
();
\Our\RedisHelper
::
delCachedFunction
(
\Redis\Db6\FavoritesStoreRedisModel
::
getInstance
(),
array
(
&
$favoritesDao
,
'getOne'
),
array
(),
array
(
$memberId
));
}
...
...
application/models/DAO/FavoritesStore.php
View file @
81353b65
...
...
@@ -27,7 +27,10 @@ class FavoritesStoreModel extends \DAO\AbstractModel {
public
function
init
(){
}
public
function
getFavoritesStores
(
$where
,
$field
)
{
$this
->
setDb
(
$this
->
dbName
);
return
$this
->
db
->
select
(
$field
)
->
where
(
$where
)
->
from
(
$this
->
_tableName
)
->
order
(
'fav_time'
,
'DESC'
)
->
fetchAll
();
}
public
function
getList
(
$where
,
$field
,
$pageIndex
,
$pageSize
,
$memberId
){
$this
->
setDb
(
$this
->
dbName
);
return
$this
->
db
->
select
(
$field
)
->
from
(
$this
->
_tableName
)
->
join
(
'han_store'
,
"han_favorites_store.store_id = han_store.store_id"
,
'inner'
)
->
join
(
'han_store_score_statistics'
,
"han_favorites_store.store_id = han_store_score_statistics.store_id"
,
'left'
)
->
where
([
'han_favorites_store.member_id'
=>
$memberId
,
'fav_type'
=>
1
])
->
where
(
$where
)
->
page
(
$pageIndex
,
$pageSize
)
->
order
(
'fav_time'
,
'DESC'
)
->
fetchAll
();
...
...
@@ -108,8 +111,8 @@ class FavoritesStoreModel extends \DAO\AbstractModel {
public
function
insertOrUpdate
(
$data
){
$this
->
setDb
(
\Our\DbNameConst
::
masterDBConnectName
);
$baseSql
=
"insert into
{
$this
->
_tableName
}
(member_id,store_id,fav_type,fav_time
) values(
{
0},{1},1,{2
}
) ON DUPLICATE KEY UPDATE fav_type=1,fav_time=VALUES (fav_time
)"
;
$sql
=
\Our\Common
::
format
(
$baseSql
,
$data
[
'member_id'
],
$data
[
'store_id'
],
$data
[
'fav_t
ime
'
]);
$baseSql
=
"insert into
{
$this
->
_tableName
}
(member_id,store_id,fav_type,fav_time
,fav_from) values(
{
0},{1},{2},{3},{4
}
) ON DUPLICATE KEY UPDATE fav_type=VALUES (fav_type),fav_time=VALUES (fav_time),fav_from = VALUES (fav_from
)"
;
$sql
=
\Our\Common
::
format
(
$baseSql
,
$data
[
'member_id'
],
$data
[
'store_id'
],
$data
[
'fav_t
ype'
],
$data
[
'fav_time'
],
$data
[
'fav_from
'
]);
$result
=
$this
->
db
->
insert
(
$this
->
_tableName
)
->
query
(
$sql
);
if
(
$result
){
if
(
$data
&&
(
isset
(
$data
[
'member_id'
])
&&
$data
[
'member_id'
])){
...
...
@@ -176,7 +179,36 @@ class FavoritesStoreModel extends \DAO\AbstractModel {
$res
=
$this
->
db
->
insert
(
$this
->
_tableName
)
->
query
(
$sql
);
return
$res
;
}
/**
* @param $storeIds
* @param $memberId
* @param int $type 取消关注:1 关注:2
* @return bool
* @throws \Our\Exception
*/
public
function
updateStoreCollecitonsCache
(
$storeIds
,
$memberId
,
$type
=
1
)
{
if
(
!
$storeIds
)
{
return
true
;
}
//删除缓存
foreach
(
$storeIds
as
$storeId
)
{
//更新店铺收藏数
$this
->
getFavoritesStoreCountByStoreId
(
$storeId
,
$type
==
1
?
-
1
:
1
);
}
if
(
is_array
(
$storeIds
)
&&
count
(
$storeIds
)
<=
20
){
foreach
(
$storeIds
as
$v
){
\Our\RedisHelper
::
delCachedFunction
(
\Redis\Db6\FavoritesStoreRedisModel
::
getInstance
(),
array
(
&
$this
,
'getOne'
),
array
(
'*'
,
array
(
'store_id'
=>
$v
,
'member_id'
=>
$memberId
)),
array
(
$memberId
));
}
}
elseif
(
!
is_array
(
$storeIds
)){
\Our\RedisHelper
::
delCachedFunction
(
\Redis\Db6\FavoritesStoreRedisModel
::
getInstance
(),
array
(
&
$this
,
'getOne'
),
array
(
'*'
,
array
(
'store_id'
=>
$storeIds
,
'member_id'
=>
$memberId
)),
array
(
$memberId
));
}
else
{
\Our\RedisHelper
::
delCachedFunction
(
\Redis\Db6\FavoritesStoreRedisModel
::
getInstance
(),
array
(
&
$this
,
'getOne'
),
array
(),
array
(
$memberId
));
}
\Our\RedisHelper
::
delCachedFunction
(
\Redis\Db6\FavoritesStoreRedisModel
::
getInstance
(),
array
(
&
$this
,
'getFavoritesStores'
),
array
(),
array
(
$memberId
));
//更新个人中心首页数量
\DAO\MemberModel
::
getInstance
()
->
_changeNum
(
\Our\NameConst
::
storeCollection
,
$memberId
,
$type
==
1
?
-
(
count
(
$storeIds
))
:
count
(
$storeIds
));
return
true
;
}
public
function
getFavoritesStoreCountByStoreId
(
$storeId
,
$num
=
0
)
{
$statisticsDb6Redis
=
\Redis\Db6\StatisticsRedisModel
::
getInstance
();
$collectCount
=
$statisticsDb6Redis
->
tableCacheGet
(
'storeCollectCount:'
.
$storeId
);
...
...
application/models/DAO/StoreScoreStatistics.php
100755 → 100644
View file @
81353b65
...
...
@@ -28,6 +28,10 @@ class StoreScoreStatisticsModel extends \DAO\AbstractModel {
$this
->
setDb
();
return
$this
->
db
->
select
(
$field
)
->
from
(
$this
->
_tableName
)
->
where
(
$where
)
->
fetchOne
();
}
public
function
getStoreScoreStatistics
(
$where
,
$field
)
{
$this
->
setDb
();
return
$this
->
db
->
select
(
$field
)
->
from
(
$this
->
_tableName
)
->
where
(
$where
)
->
fetchAll
();
}
public
function
insertOrUpdate
(
$data
){
$this
->
setDb
(
\Our\DbNameConst
::
masterDBConnectName
);
$baseSql
=
"insert into
{
$this
->
_tableName
}
(store_id,evaluation_score,evaluation_number) values(
{
0},{1},{2
}
) ON DUPLICATE KEY UPDATE evaluation_number = VALUES(evaluation_number),evaluation_score=VALUES(evaluation_score)"
;
...
...
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