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
71d11674
Commit
71d11674
authored
Sep 05, 2018
by
zhz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
goods
parent
970fe2ab
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
12 deletions
+67
-12
Goods.php
application/controllers/Goods.php
+1
-1
GoodsCommonService.php
application/models/Business/Goods/GoodsCommonService.php
+66
-10
Abstract.php
application/models/Redis/Db4/Abstract.php
+0
-1
No files found.
application/controllers/Goods.php
View file @
71d11674
...
...
@@ -18,7 +18,7 @@ class GoodsController extends \Our\Controller_AbstractIndex {
$goodsInfo
[
'freeShippingPrice'
]
=
$store
[
'freeShippingPrice'
];
$goodsInfo
[
'isQuality'
]
=
$store
[
'isQuality'
];
$evaluation
=
$this
->
goodsService
->
getEvaluation
(
$this
->
req
[
\Our\NameConst
::
data
]);
$recomndGoods
=
$this
->
goodsService
->
getRecommendGoods
(
$goodsInfo
[
'storeId'
],
$this
->
memberId
);
$recomndGoods
=
$this
->
goodsService
->
getRecommendGoods
(
$goodsInfo
[
'storeId'
],
$this
->
req
[
\Our\NameConst
::
data
][
'goodsCommonId'
],
$this
->
memberId
);
$groups
=
\Business\Goods\GroupSaleServiceModel
::
getInstance
()
->
getGroupByCommonId
(
$this
->
req
[
\Our\NameConst
::
data
][
'goodsCommonId'
],
$goodsInfo
[
'storeId'
]);
$couponService
=
\Business\Coupon\CouponServiceModel
::
getInstance
();
$coupons
=
$couponService
->
getGoodsCoupons
(
array
(
'storeId'
=>
$goodsInfo
[
'storeId'
]),
$this
->
memberId
);
...
...
application/models/Business/Goods/GoodsCommonService.php
View file @
71d11674
...
...
@@ -938,19 +938,75 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
* @param null $memberId
* @return array
*/
public
function
getRecommendGoods
(
$storeId
,
$memberId
=
null
){
public
function
getRecommendGoods
(
$storeId
,
$
goodsCommonId
,
$
memberId
=
null
){
$commonIds
=
[];
//周销量前3取一个
$existIds
[]
=
$goodsCommonId
;
$goodsCommonRedis
=
\Redis\Db4\GoodsCommonRedisModel
::
getInstance
();
$arr
=
$goodsCommonRedis
->
tableSRandMember
(
'weekSales:'
.
$storeId
,
1
);
//本周销售过的商品取一个
$commonIds
=
array_merge
(
$commonIds
,
$arr
);
$arr
=
$goodsCommonRedis
->
tableSRandMember
(
'weekSaleGoods:'
.
$storeId
,
2
);
//推荐商品取一个
$commonIds
=
array_merge
(
$arr
,
$commonIds
);
$arr
=
$goodsCommonRedis
->
tableSRandMember
(
'recommendGoods:'
.
$storeId
,
4
-
count
(
$commonIds
));
//周销量前3取一个
if
(
$goodsCommonRedis
->
tableSIsMember
(
'weekSales:'
.
$storeId
,
$goodsCommonId
))
{
$tempArr
[]
=
$goodsCommonId
;
}
if
(
$goodsCommonRedis
->
sIsMember
(
'weekSales:'
.
$storeId
,
$goodsCommonId
))
{
$weekSales
=
$goodsCommonRedis
->
smembers
(
'weekSales:'
.
$storeId
);
if
(
$weekSales
)
{
$arr
=
array_merge
(
array_diff
(
$weekSales
,
$existIds
));
if
(
$arr
)
{
shuffle
(
$arr
);
$ret
=
array_pop
(
$arr
);
if
(
$ret
)
{
$commonIds
[]
=
$ret
;
$existIds
[]
=
$ret
;
}
}
}
}
else
{
$arr
=
$goodsCommonRedis
->
tableSRandMember
(
'weekSales:'
.
$storeId
,
1
);
}
$commonIds
=
array_merge
(
$arr
,
$commonIds
);
//本周销售过的商品取两个
//$commonIds = array_merge($commonIds,$arr);
//$arr = $goodsCommonRedis->tableSRandMember('weekSaleGoods:'.$storeId,2);
//推荐商品取一个
//$commonIds = array_merge($arr,$commonIds);
//$arr = $goodsCommonRedis->tableSRandMember('recommendGoods:'.$storeId,4-count($commonIds));
//$commonIds = array_merge($arr,$commonIds);
$weekSaleGoods
=
$goodsCommonRedis
->
smembers
(
'weekSaleGoods:'
.
$storeId
);
if
(
$weekSaleGoods
)
{
$arr
=
array_merge
(
array_diff
(
$weekSaleGoods
,
$existIds
));
if
(
$arr
)
{
shuffle
(
$arr
);
$ret
=
array_pop
(
$arr
);
if
(
$ret
)
{
$commonIds
[]
=
$ret
;
$existIds
[]
=
$ret
;
}
$ret
=
array_pop
(
$arr
);
if
(
$ret
)
{
$commonIds
[]
=
$ret
;
$existIds
[]
=
$ret
;
}
}
}
$recommendGoods
=
$goodsCommonRedis
->
smembers
(
'weekSaleGoods:'
.
$storeId
);
if
(
$recommendGoods
)
{
$arr
=
array_merge
(
array_diff
(
$recommendGoods
,
$existIds
));
if
(
$arr
)
{
shuffle
(
$arr
);
while
(
true
)
{
$ret
=
array_pop
(
$arr
);
if
(
$ret
)
{
$commonIds
[]
=
$ret
;
$existIds
[]
=
$ret
;
}
else
{
break
;
}
if
(
count
(
$commonIds
)
==
4
){
break
;
}
}
}
}
$goods
=
[];
if
(
$commonIds
){
//该用户是否有参加销售活动
...
...
application/models/Redis/Db4/Abstract.php
View file @
71d11674
...
...
@@ -99,7 +99,6 @@ class AbstractModel extends \Redis\AbstractModel {
public
function
tableSRandMember
(
$h
,
$count
=
null
){
return
$this
->
sRandMember
(
$this
->
calcKey
(
$h
),
$count
);
}
public
function
tableHIncrBy
(
$h
,
$key
,
$keysvalue
){
return
$this
->
hIncrBy
(
$this
->
calcKey
(
$h
),
$key
,
$keysvalue
);
}
...
...
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