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
26f95ff0
Commit
26f95ff0
authored
Sep 05, 2018
by
zhz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
goods
parent
dea92011
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
54 deletions
+74
-54
GoodsCommonService.php
application/models/Business/Goods/GoodsCommonService.php
+74
-54
No files found.
application/models/Business/Goods/GoodsCommonService.php
View file @
26f95ff0
...
@@ -942,72 +942,92 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
...
@@ -942,72 +942,92 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
$commonIds
=
[];
$commonIds
=
[];
$existIds
[]
=
$goodsCommonId
;
$existIds
[]
=
$goodsCommonId
;
$goodsCommonRedis
=
\Redis\Db4\GoodsCommonRedisModel
::
getInstance
();
$goodsCommonRedis
=
\Redis\Db4\GoodsCommonRedisModel
::
getInstance
();
//周销量前3取一个
// if($goodsCommonRedis->tableSIsMember('weekSales:'.$storeId, $goodsCommonId)) {
// if($goodsCommonRedis->tableSIsMember('weekSales:'.$storeId, $goodsCommonId)) {
// $tempArr[] = $goodsCommonId;
// $tempArr[] = $goodsCommonId;
// }
// }
$log
=
\Our\Log
::
getInstance
();
//周销量前3取一个
// $log->write(print_r($data, true));
$arr
=
$goodsCommonRedis
->
tableSRandMember
(
'weekSales:'
.
$storeId
,
2
);
$weekSales
=
$goodsCommonRedis
->
tableSmembers
(
'weekSales:'
.
$storeId
);
$arr
=
array_merge
(
array_diff
(
$arr
,
$existIds
));
$log
->
write
(
json_encode
(
$weekSales
));
if
(
$arr
)
{
if
(
$weekSales
)
{
$ret
=
array_pop
(
$arr
);
$arr
=
array_merge
(
array_diff
(
$weekSales
,
$existIds
));
$commonIds
[]
=
$ret
;
if
(
$arr
)
{
$existIds
[]
=
$ret
;
shuffle
(
$arr
);
$ret
=
array_pop
(
$arr
);
if
(
$ret
)
{
$commonIds
[]
=
$ret
;
$existIds
[]
=
$ret
;
}
}
}
}
//本周销售过的商品取两个
//本周销售过的商品取两个
//$commonIds = array_merge($commonIds,$arr);
//$commonIds = array_merge($commonIds,$arr);
//$arr = $goodsCommonRedis->tableSRandMember('weekSaleGoods:'.$storeId,2);
$arr
=
$goodsCommonRedis
->
tableSRandMember
(
'weekSaleGoods:'
.
$storeId
,
count
(
$existIds
)
+
2
);
//推荐商品取一个
$arr
=
array_merge
(
array_diff
(
$arr
,
$existIds
));
//$commonIds = array_merge($arr,$commonIds);
if
(
$arr
)
{
//$arr = $goodsCommonRedis->tableSRandMember('recommendGoods:'.$storeId,4-count($commonIds));
$ret
=
array_pop
(
$arr
);
$commonIds
[]
=
$ret
;
//$commonIds = array_merge($arr,$commonIds);
$existIds
[]
=
$ret
;
$weekSaleGoods
=
$goodsCommonRedis
->
tableSmembers
(
'weekSaleGoods:'
.
$storeId
);
$log
->
write
(
json_encode
(
$weekSaleGoods
));
if
(
$weekSaleGoods
)
{
$arr
=
array_merge
(
array_diff
(
$weekSaleGoods
,
$existIds
));
if
(
$arr
)
{
if
(
$arr
)
{
shuffle
(
$arr
);
$ret
=
array_pop
(
$arr
);
if
(
$ret
)
{
$commonIds
[]
=
$ret
;
$existIds
[]
=
$ret
;
}
$ret
=
array_pop
(
$arr
);
$ret
=
array_pop
(
$arr
);
if
(
$ret
)
{
$commonIds
[]
=
$ret
;
$commonIds
[]
=
$ret
;
$existIds
[]
=
$ret
;
$existIds
[]
=
$ret
;
}
}
}
}
}
$recommendGoods
=
$goodsCommonRedis
->
tableSmembers
(
'recommendGoods:'
.
$storeId
);
//推荐商品取一个
$log
->
write
(
json_encode
(
$recommendGoods
));
//$commonIds = array_merge($arr,$commonIds);
if
(
$recommendGoods
)
{
$arr
=
$goodsCommonRedis
->
tableSRandMember
(
'recommendGoods:'
.
$storeId
,(
4
-
count
(
$commonIds
)
+
count
(
$existIds
)));
$arr
=
array_merge
(
array_diff
(
$recommendGoods
,
$existIds
));
$arr
=
array_merge
(
array_diff
(
$arr
,
$existIds
));
if
(
$arr
)
{
if
(
$arr
)
{
shuffle
(
$arr
);
foreach
(
$arr
as
$v
)
{
while
(
true
)
{
$commonIds
[]
=
$v
;
$ret
=
array_pop
(
$arr
);
if
(
$ret
)
{
$commonIds
[]
=
$ret
;
$existIds
[]
=
$ret
;
}
else
{
break
;
}
if
(
count
(
$commonIds
)
==
4
){
break
;
}
}
}
}
}
}
//$commonIds = array_merge($arr,$commonIds);
// $weekSales = $goodsCommonRedis->tableSmembers('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;
// }
// }
// }
//
//
// $weekSaleGoods = $goodsCommonRedis->tableSmembers('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->tableSmembers('recommendGoods:'.$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
=
[];
$goods
=
[];
if
(
$commonIds
){
if
(
$commonIds
){
//该用户是否有参加销售活动
//该用户是否有参加销售活动
...
...
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