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
75ccd79f
Commit
75ccd79f
authored
Nov 07, 2018
by
liuyuzhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
首页及关注店铺问题
parent
554b7434
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
102 additions
and
8 deletions
+102
-8
Collection.php
application/controllers/Collection.php
+10
-0
Home.php
application/controllers/Home.php
+12
-0
User.php
application/controllers/User.php
+7
-3
DescribeConst.php
application/library/Our/DescribeConst.php
+2
-0
GoodsClassService.php
application/models/Business/Goods/GoodsClassService.php
+1
-1
StoreService.php
application/models/Business/Store/StoreService.php
+33
-0
MemberService.php
application/models/Business/User/MemberService.php
+21
-0
FavoritesStore.php
application/models/DAO/FavoritesStore.php
+8
-2
CodeConfig.php
application/models/Error/CodeConfig.php
+6
-0
application.ini
conf/application.ini
+2
-2
No files found.
application/controllers/Collection.php
100755 → 100644
View file @
75ccd79f
...
...
@@ -31,6 +31,16 @@ class CollectionController extends \Our\Controller_AbstractApi {
}
/**
* 扫码关注店铺
*/
public
function
updateScanStoreAction
(){
\Business\Store\StoreServiceModel
::
getInstance
()
->
updateFavoritesStore
(
$this
->
req
[
\Our\NameConst
::
data
],
$this
->
memberId
);
$this
->
success
(
new
\stdClass
(),
\Our\DescribeConst
::
scanSuccess
);
}
/**
* 关注 商品
*
...
...
application/controllers/Home.php
View file @
75ccd79f
...
...
@@ -43,10 +43,22 @@ class HomeController extends \Our\Controller_AbstractIndex{
$shareInfo
=
\Business\Common\CommonServiceModel
::
getInstance
()
->
getShareInfo
(
\Our\ApiConst
::
sharePlat
);
$returnData
[
'shareInfo'
]
=
$shareInfo
;
$storeId
=
$this
->
getMyFavoritesStoreAction
(
true
);
$returnData
[
'relateStoreId'
]
=
(
int
)
$storeId
;
$this
->
success
(
$returnData
);
}
public
function
getMyFavoritesStoreAction
(
$flag
=
false
){
$mebmerService
=
\Business\User\MemberServiceModel
::
getInstance
();
$memberId
=
$this
->
sess
->
get
(
'member_id'
);
$storeId
=
$mebmerService
->
getMyFavoritesStore
(
$memberId
);
if
(
$flag
){
return
$storeId
;
}
$this
->
success
(
$storeId
);
}
/**
* 设置当前地址
...
...
application/controllers/User.php
View file @
75ccd79f
...
...
@@ -66,7 +66,8 @@ class UserController extends \Our\Controller_AbstractIndex {
$this
->
sess
[
NameConst
::
sessionKey
]
=
$this
->
key
;
$member
[
NameConst
::
sessionKey
]
=
$this
->
key
;
$this
->
memberService
->
saveMember
(
$member
);
$this
->
success
(
array
(
'key'
=>
$this
->
key
,
'memberName'
=>
$member
[
'member_name'
],
'memberAvatar'
=>
$member
[
'memberAvatarUrl'
],
'memberId'
=>
(
int
)
$member
[
'member_id'
]));
$storeId
=
$this
->
memberService
->
getMyFavoritesStore
(
$member
[
'member_id'
]);
$this
->
success
(
array
(
'key'
=>
$this
->
key
,
'memberName'
=>
$member
[
'member_name'
],
'memberAvatar'
=>
$member
[
'memberAvatarUrl'
],
'memberId'
=>
(
int
)
$member
[
'member_id'
],
'relateStoreId'
=>
(
int
)
$storeId
));
}
else
{
ErrorModel
::
throwException
(
CodeConfigModel
::
errorUsernameOrPassword
);
}
...
...
@@ -102,7 +103,9 @@ class UserController extends \Our\Controller_AbstractIndex {
$this
->
sess
[
NameConst
::
sessionKey
]
=
$this
->
key
;
$member
[
NameConst
::
sessionKey
]
=
$this
->
key
;
//$this->memberService->saveMember($member);
$this
->
success
(
array
(
'key'
=>
$this
->
key
,
'memberName'
=>
$member
[
'member_name'
],
'memberAvatar'
=>
$member
[
'memberAvatarUrl'
]));
$storeId
=
$this
->
memberService
->
getMyFavoritesStore
(
$member
[
'member_id'
]);
$this
->
success
(
array
(
'key'
=>
$this
->
key
,
'memberName'
=>
$member
[
'member_name'
],
'memberAvatar'
=>
$member
[
'memberAvatarUrl'
],
'relateStoreId'
=>
(
int
)
$storeId
));
}
ErrorModel
::
throwException
(
CodeConfigModel
::
wxAuthInfoLoginFailed
);
...
...
@@ -154,7 +157,8 @@ class UserController extends \Our\Controller_AbstractIndex {
$member
[
NameConst
::
sessionKey
]
=
$this
->
key
;
$member
[
'login_time'
]
=
TIMESTAMP
;
$this
->
memberService
->
saveMember
(
$member
);
$this
->
success
(
array
(
'userFlag'
=>
\Our\ApiConst
::
one
,
'key'
=>
$this
->
key
,
'memberName'
=>
$member
[
'member_name'
],
'memberAvatar'
=>
$member
[
'memberAvatarUrl'
],
'memberId'
=>
(
int
)
$member
[
'member_id'
]));
$storeId
=
$this
->
memberService
->
getMyFavoritesStore
(
$member
[
'member_id'
]);
$this
->
success
(
array
(
'userFlag'
=>
\Our\ApiConst
::
one
,
'key'
=>
$this
->
key
,
'memberName'
=>
$member
[
'member_name'
],
'memberAvatar'
=>
$member
[
'memberAvatarUrl'
],
'memberId'
=>
(
int
)
$member
[
'member_id'
],
'relateStoreId'
=>
(
int
)
$storeId
));
}
else
{
$this
->
success
(
array
(
'userFlag'
=>
\Our\ApiConst
::
zero
));
}
...
...
application/library/Our/DescribeConst.php
View file @
75ccd79f
...
...
@@ -76,6 +76,8 @@ class DescribeConst
const
collectSuccess
=
'关注成功'
;
const
scanSuccess
=
'扫码关注成功'
;
const
cancelCollectSuccess
=
'取消关注成功'
;
const
moveToFavoritesSuccess
=
'移入收藏夹成功'
;
...
...
application/models/Business/Goods/GoodsClassService.php
View file @
75ccd79f
...
...
@@ -193,7 +193,7 @@ class GoodsClassServiceModel extends \Business\AbstractModel{
//判断签约分类是否可以为当前用户提供服务,并且记录这些店铺对应的store_id
if
(
$inAreaFlag
){
$store
=
$storeDao
->
getStoreInfoCache
(
$signClass
[
'store_id'
]);
$class_distance
=
\Our\CommonExtension
::
getDistance
(
$lat
,
$lng
,
$store
[
'store_latitude'
],
$s
ignClass
[
'store_latitude'
],
1
);
$class_distance
=
\Our\CommonExtension
::
getDistance
(
$lat
,
$lng
,
$store
[
'store_latitude'
],
$s
tore
[
'store_latitude'
],
1
);
$class
=
$signClass
;
$class
[
'class_distance'
]
=
$class_distance
;
$returnClass
[
$class_distance
]
=
$class
;
...
...
application/models/Business/Store/StoreService.php
View file @
75ccd79f
...
...
@@ -49,6 +49,8 @@ class StoreServiceModel extends \Business\AbstractModel{
$storeMembers
[]
=
$storeMember
;
$favoritesStoreDao
=
\DAO\FavoritesStoreModel
::
getInstance
();
$result
=
$favoritesStoreDao
->
insertAll
(
$storeMembers
);
$favoritesDao
=
\DAO\FavoritesStoreModel
::
getInstance
();
\Our\RedisHelper
::
delCachedFunction
(
\Redis\Db6\FavoritesStoreRedisModel
::
getInstance
(),
array
(
&
$favoritesDao
,
'getOne'
),
array
(),
array
(
$memberId
));
}
else
{
$sess
=
\Yaf\Session
::
getInstance
();
$scan_store_ids
=
$sess
->
get
(
'scan_store_ids'
);
...
...
@@ -373,6 +375,37 @@ class StoreServiceModel extends \Business\AbstractModel{
}
}
/**
* 上传当前用户的关注店铺
* @param $param
* @param $memberId
*/
public
function
updateFavoritesStore
(
$param
,
$memberId
){
if
(
!
(
isset
(
$param
[
'storeId'
])
&&
$param
[
'storeId'
])){
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
emptyScanStoreId
);
}
$storeId
=
trim
(
$param
[
'storeId'
]);
$storeInfo
=
\DAO\StoreModel
::
getInstance
()
->
get
(
$storeId
,
false
);
if
(
!
$storeInfo
){
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
emptyScanStoreInfo
);
}
$storeMembers
=
array
();
$storeMember
=
array
();
$storeMember
[
'store_id'
]
=
$storeId
;
$storeMember
[
'member_id'
]
=
$memberId
;
$storeMember
[
'fav_from'
]
=
\Our\ApiConst
::
scanFavor
;
$storeMember
[
'fav_type'
]
=
\Our\ApiConst
::
one
;
$storeMembers
[]
=
$storeMember
;
$favoritesStoreDao
=
\DAO\FavoritesStoreModel
::
getInstance
();
$result
=
$favoritesStoreDao
->
insertAll
(
$storeMembers
);
if
(
!
$result
){
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
saveScanStoreInfoFailed
);
}
\Our\RedisHelper
::
delCachedFunction
(
\Redis\Db6\FavoritesStoreRedisModel
::
getInstance
(),
array
(
&
$favoritesStoreDao
,
'getOne'
),
array
(),
array
(
$memberId
));
return
true
;
}
/**
* 获取搜索页推荐关键字
* @param $param
...
...
application/models/Business/User/MemberService.php
View file @
75ccd79f
...
...
@@ -361,6 +361,8 @@ class MemberServiceModel extends \Business\AbstractModel
\Our\Log
::
getInstance
()
->
write
(
json_encode
(
$storeMembers
)
.
'扫码数据写入失败'
);
return
false
;
}
$favoritesDao
=
\DAO\FavoritesStoreModel
::
getInstance
();
\Our\RedisHelper
::
delCachedFunction
(
\Redis\Db6\FavoritesStoreRedisModel
::
getInstance
(),
array
(
&
$favoritesDao
,
'getOne'
),
array
(),
array
(
$memberId
));
}
$scan_sale_ids
=
$sess
->
get
(
'scan_sale_ids'
);
if
(
$scan_sale_ids
){
...
...
@@ -1077,5 +1079,24 @@ class MemberServiceModel extends \Business\AbstractModel
}
/**
* 获取当前用户最新的扫码关注店铺
* @param $memberId
* @return int
* @throws \Our\Exception
*/
public
function
getMyFavoritesStore
(
$memberId
){
if
(
$memberId
){
$favoritesDao
=
\DAO\FavoritesStoreModel
::
getInstance
();
$favStore
=
\Our\RedisHelper
::
cachedFunction
(
\Redis\Db6\FavoritesStoreRedisModel
::
getInstance
(),
array
(
&
$favoritesDao
,
'getOne'
),
array
(
'store_id'
,
array
(
'fav_from'
=>
\Our\ApiConst
::
scanFavor
,
'member_id'
=>
$memberId
)),
\Our\ApiConst
::
oneDaySecond
,
array
(
$memberId
));
if
(
$favStore
&&
$favStore
[
'store_id'
]){
return
$favStore
[
'store_id'
];
}
}
return
\Our\ApiConst
::
zero
;
}
}
application/models/DAO/FavoritesStore.php
View file @
75ccd79f
...
...
@@ -45,9 +45,15 @@ class FavoritesStoreModel extends \DAO\AbstractModel {
return
$this
->
db
->
fetchAll
();
}
public
function
getOne
(
$field
,
$where
){
public
function
getOne
(
$field
,
$where
,
$order
=
array
(
'fav_time'
=>
'desc'
)
){
$this
->
setDb
(
$this
->
dbName
);
return
$this
->
db
->
select
(
$field
)
->
from
(
$this
->
_tableName
)
->
where
(
$where
)
->
fetchOne
();
if
(
$order
){
foreach
(
$order
as
$key
=>
$value
){
$this
->
db
->
order
(
$key
,
$value
);
}
}
$result
=
$this
->
db
->
select
(
$field
)
->
from
(
$this
->
_tableName
)
->
where
(
$where
)
->
fetchOne
();
return
$result
;
}
public
function
insert
(
$param
){
...
...
application/models/Error/CodeConfig.php
View file @
75ccd79f
...
...
@@ -127,6 +127,9 @@ class CodeConfigModel
const
emptyStoreId
=
40007
;
const
saveReportError
=
40008
;
const
stroeReceiveError
=
40009
;
const
emptyScanStoreId
=
40010
;
const
emptyScanStoreInfo
=
40011
;
const
saveScanStoreInfoFailed
=
40012
;
//购物车
const
wrongCartType
=
50001
;
...
...
@@ -530,6 +533,9 @@ class CodeConfigModel
self
::
emptyReportStoreType
=>
'举报类型不能为空'
,
self
::
emptyStores
=>
'没找到相关店铺'
,
self
::
stroeReceiveError
=>
'店铺接单错误'
,
self
::
emptyScanStoreId
=>
'扫码关注店铺ID为空'
,
self
::
emptyScanStoreInfo
=>
'扫码关注店铺不存在'
,
self
::
saveScanStoreInfoFailed
=>
'扫码店铺保存失败'
,
//购物车相关
self
::
wrongCartType
=>
'加入购物车类型不能为空'
,
...
...
conf/application.ini
View file @
75ccd79f
...
...
@@ -395,7 +395,7 @@ elastic.master.host="192.168.1.201"
elastic.master.port
=
"9200"
elastic.master.scheme
=
"http"
;
[lyz
test
: common]
[lyz : common]
; 数据库配置
resources.database.params.driver
=
"pdo_mysql"
resources.database.params.hostname
=
"127.0.0.1"
...
...
@@ -442,7 +442,7 @@ elastic.master.host="192.168.1.201"
elastic.master.port
=
"9200"
elastic.master.scheme
=
"http"
;
[lyz : common]
[lyz
test
: common]
; 数据库配置
resources.database.params.driver
=
"pdo_mysql"
resources.database.params.hostname
=
"127.0.0.1"
...
...
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