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
b608d6a6
Commit
b608d6a6
authored
Sep 06, 2018
by
wwccw0591
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master_dev' of git.shenbd.com:qm-develop/shenbd into ccw
parents
5c8c83b4
cd45eb95
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
148 additions
and
24 deletions
+148
-24
Goods.php
application/controllers/Goods.php
+1
-1
ArrayConst.php
application/library/Our/ArrayConst.php
+2
-1
GoodsCommonService.php
application/models/Business/Goods/GoodsCommonService.php
+90
-10
AddressService.php
application/models/Business/User/AddressService.php
+52
-10
Abstract.php
application/models/Redis/Db4/Abstract.php
+3
-2
No files found.
application/controllers/Goods.php
View file @
b608d6a6
...
@@ -18,7 +18,7 @@ class GoodsController extends \Our\Controller_AbstractIndex {
...
@@ -18,7 +18,7 @@ class GoodsController extends \Our\Controller_AbstractIndex {
$goodsInfo
[
'freeShippingPrice'
]
=
$store
[
'freeShippingPrice'
];
$goodsInfo
[
'freeShippingPrice'
]
=
$store
[
'freeShippingPrice'
];
$goodsInfo
[
'isQuality'
]
=
$store
[
'isQuality'
];
$goodsInfo
[
'isQuality'
]
=
$store
[
'isQuality'
];
$evaluation
=
$this
->
goodsService
->
getEvaluation
(
$this
->
req
[
\Our\NameConst
::
data
]);
$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'
]);
$groups
=
\Business\Goods\GroupSaleServiceModel
::
getInstance
()
->
getGroupByCommonId
(
$this
->
req
[
\Our\NameConst
::
data
][
'goodsCommonId'
],
$goodsInfo
[
'storeId'
]);
$couponService
=
\Business\Coupon\CouponServiceModel
::
getInstance
();
$couponService
=
\Business\Coupon\CouponServiceModel
::
getInstance
();
$coupons
=
$couponService
->
getGoodsCoupons
(
array
(
'storeId'
=>
$goodsInfo
[
'storeId'
]),
$this
->
memberId
);
$coupons
=
$couponService
->
getGoodsCoupons
(
array
(
'storeId'
=>
$goodsInfo
[
'storeId'
]),
$this
->
memberId
);
...
...
application/library/Our/ArrayConst.php
100755 → 100644
View file @
b608d6a6
...
@@ -65,7 +65,8 @@ class ArrayConst
...
@@ -65,7 +65,8 @@ class ArrayConst
NameConst
::
cityCode
=>
'0591'
,
NameConst
::
cityCode
=>
'0591'
,
NameConst
::
lat
=>
'26.053183'
,
NameConst
::
lat
=>
'26.053183'
,
NameConst
::
lng
=>
'119.24174'
,
NameConst
::
lng
=>
'119.24174'
,
NameConst
::
address
=>
'横一号路特力林科技大厦'
NameConst
::
address
=>
'横一号路特力林科技大厦'
,
'default'
=>
\Our\ApiConst
::
one
);
);
//小程序账号
//小程序账号
...
...
application/models/Business/Goods/GoodsCommonService.php
View file @
b608d6a6
...
@@ -938,19 +938,99 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
...
@@ -938,19 +938,99 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
* @param null $memberId
* @param null $memberId
* @return array
* @return array
*/
*/
public
function
getRecommendGoods
(
$storeId
,
$memberId
=
null
){
public
function
getRecommendGoods
(
$storeId
,
$
goodsCommonId
,
$
memberId
=
null
){
$commonIds
=
[];
$commonIds
=
[];
//周销量前3取一个
$existIds
[]
=
$goodsCommonId
;
$goodsCommonRedis
=
\Redis\Db4\GoodsCommonRedisModel
::
getInstance
();
$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
));
$commonIds
=
array_merge
(
$arr
,
$commonIds
);
// if($goodsCommonRedis->tableSIsMember('weekSales:'.$storeId, $goodsCommonId)) {
// $tempArr[] = $goodsCommonId;
// }
//周销量前3取一个
$arr
=
$goodsCommonRedis
->
tableSRandMember
(
'weekSales:'
.
$storeId
,
2
);
$arr
=
array_merge
(
array_diff
(
$arr
,
$existIds
));
if
(
$arr
)
{
$ret
=
array_pop
(
$arr
);
$commonIds
[]
=
$ret
;
$existIds
[]
=
$ret
;
}
//本周销售过的商品取两个
//$commonIds = array_merge($commonIds,$arr);
$arr
=
$goodsCommonRedis
->
tableSRandMember
(
'weekSaleGoods:'
.
$storeId
,
count
(
$existIds
)
+
2
);
$arr
=
array_merge
(
array_diff
(
$arr
,
$existIds
));
if
(
$arr
)
{
$ret
=
array_pop
(
$arr
);
$commonIds
[]
=
$ret
;
$existIds
[]
=
$ret
;
if
(
$arr
)
{
$ret
=
array_pop
(
$arr
);
$commonIds
[]
=
$ret
;
$existIds
[]
=
$ret
;
}
}
//推荐商品取一个
//$commonIds = array_merge($arr,$commonIds);
$arr
=
$goodsCommonRedis
->
tableSRandMember
(
'recommendGoods:'
.
$storeId
,(
4
-
count
(
$commonIds
)
+
count
(
$existIds
)));
$arr
=
array_merge
(
array_diff
(
$arr
,
$existIds
));
if
(
$arr
)
{
foreach
(
$arr
as
$v
)
{
$commonIds
[]
=
$v
;
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
){
//该用户是否有参加销售活动
//该用户是否有参加销售活动
...
...
application/models/Business/User/AddressService.php
View file @
b608d6a6
...
@@ -78,7 +78,14 @@ class AddressServiceModel extends \Business\AbstractModel {
...
@@ -78,7 +78,14 @@ class AddressServiceModel extends \Business\AbstractModel {
$addresses
[]
=
$address
;
$addresses
[]
=
$address
;
$returnAddress
=
array
(
'returnAddressId'
=>
$currentAddress
[
'addressId'
],
'choosedAddressFlag'
=>
$currentAddress
[
'chooseFlag'
],
'addresses'
=>
$addresses
);
$returnAddress
=
array
(
'returnAddressId'
=>
$currentAddress
[
'addressId'
],
'choosedAddressFlag'
=>
$currentAddress
[
'chooseFlag'
],
'addresses'
=>
$addresses
);
}
else
{
}
else
{
$returnAddress
=
array
(
'returnAddressId'
=>
$currentAddress
[
'addressId'
],
'choosedAddressFlag'
=>
$currentAddress
[
'chooseFlag'
]);
$returnAddress
=
array
(
'returnAddressId'
=>
$currentAddress
[
'addressId'
],
'choosedAddressFlag'
=>
isset
(
$currentAddress
[
'chooseFlag'
])
&&
$currentAddress
[
'chooseFlag'
]
?
$currentAddress
[
'chooseFlag'
]
:
\Our\ApiConst
::
zero
);
if
(
$memberId
){
$myAddresses
=
$this
->
getMyCurrentAddressByMemberId
(
$memberId
);
if
(
$myAddresses
){
$returnAddress
[
'addresses'
]
=
$myAddresses
;
}
}
}
}
}
else
{
}
else
{
if
(
isset
(
$data
[
'choosedFlag'
])
&&
$data
[
'choosedFlag'
])
{
//设置地址时执行到这里属于非法情况
if
(
isset
(
$data
[
'choosedFlag'
])
&&
$data
[
'choosedFlag'
])
{
//设置地址时执行到这里属于非法情况
...
@@ -153,12 +160,11 @@ class AddressServiceModel extends \Business\AbstractModel {
...
@@ -153,12 +160,11 @@ class AddressServiceModel extends \Business\AbstractModel {
if
(
$chooseFlag
){
if
(
$chooseFlag
){
$address
[
'chooseFlag'
]
=
$chooseFlag
;
$address
[
'chooseFlag'
]
=
$chooseFlag
;
}
else
{
}
else
{
if
(
$currentAddress
&&
$tempLatLng
){
$address
[
'chooseFlag'
]
=
\Our\ApiConst
::
zero
;
if
(
$currentAddress
&&
$tempLatLng
&&!
(
isset
(
$where
[
'default'
])
&&
$where
[
'default'
])){
$sameFlag
=
$addressDao
->
checkSessAddress
(
$tempLatLng
,
$currentAddress
);
$sameFlag
=
$addressDao
->
checkSessAddress
(
$tempLatLng
,
$currentAddress
);
if
(
$sameFlag
){
if
(
$sameFlag
){
$address
[
'chooseFlag'
]
=
\Our\ApiConst
::
one
;
$address
[
'chooseFlag'
]
=
\Our\ApiConst
::
one
;
}
else
{
$address
[
'chooseFlag'
]
=
\Our\ApiConst
::
zero
;
}
}
}
}
}
}
...
@@ -166,6 +172,8 @@ class AddressServiceModel extends \Business\AbstractModel {
...
@@ -166,6 +172,8 @@ class AddressServiceModel extends \Business\AbstractModel {
return
array
(
'returnAddressId'
=>
$address
[
'addressId'
],
'choosedAddressFlag'
=>
$address
[
'chooseFlag'
]
?
\Our\ApiConst
::
one
:
\Our\ApiConst
::
zero
);
return
array
(
'returnAddressId'
=>
$address
[
'addressId'
],
'choosedAddressFlag'
=>
$address
[
'chooseFlag'
]
?
\Our\ApiConst
::
one
:
\Our\ApiConst
::
zero
);
}
}
$address
=
array
();
$columns
=
$this
->
getChoosedAddressColumns
();
$columns
=
$this
->
getChoosedAddressColumns
();
$condition
[
'member_id'
]
=
$memberId
;
$condition
[
'member_id'
]
=
$memberId
;
$condition
[
'citycode'
]
=
$where
[
'cityCode'
];
$condition
[
'citycode'
]
=
$where
[
'cityCode'
];
...
@@ -173,7 +181,6 @@ class AddressServiceModel extends \Business\AbstractModel {
...
@@ -173,7 +181,6 @@ class AddressServiceModel extends \Business\AbstractModel {
$limit
=
\Our\ApiConst
::
defaultAddressCount
;
$limit
=
\Our\ApiConst
::
defaultAddressCount
;
//1、判断当前用户的地址列表中是否存在和当前经纬度坐标小于200的地址(当前经纬度是否存在对应收货地址)
//1、判断当前用户的地址列表中是否存在和当前经纬度坐标小于200的地址(当前经纬度是否存在对应收货地址)
$addressList
=
\Our\RedisHelper
::
cachedFunction
(
\Redis\Db8\AddressRedisModel
::
getInstance
(),
array
(
&
$addressDao
,
'selectByWhere'
),
array
(
$condition
,
$columns
),
\Our\ApiConst
::
oneHour
,
array
(
$memberId
));
$addressList
=
\Our\RedisHelper
::
cachedFunction
(
\Redis\Db8\AddressRedisModel
::
getInstance
(),
array
(
&
$addressDao
,
'selectByWhere'
),
array
(
$condition
,
$columns
),
\Our\ApiConst
::
oneHour
,
array
(
$memberId
));
$address
=
array
();
if
(
$addressList
){
if
(
$addressList
){
$newAddressList
=
array
();
$newAddressList
=
array
();
foreach
(
$addressList
as
$addr
){
foreach
(
$addressList
as
$addr
){
...
@@ -217,14 +224,13 @@ class AddressServiceModel extends \Business\AbstractModel {
...
@@ -217,14 +224,13 @@ class AddressServiceModel extends \Business\AbstractModel {
$address
[
'chooseFlag'
]
=
$chooseFlag
;
$address
[
'chooseFlag'
]
=
$chooseFlag
;
$choosedAddressFlag
=
\Our\ApiConst
::
one
;
$choosedAddressFlag
=
\Our\ApiConst
::
one
;
}
else
{
}
else
{
if
(
$currentAddress
&&
$tempLatLng
){
$address
[
'chooseFlag'
]
=
\Our\ApiConst
::
zero
;
$choosedAddressFlag
=
\Our\ApiConst
::
zero
;
if
(
$currentAddress
&&
$tempLatLng
&&!
(
isset
(
$where
[
'default'
])
&&
$where
[
'default'
])){
$sameFlag
=
$addressDao
->
checkSessAddress
(
$tempLatLng
,
$currentAddress
);
$sameFlag
=
$addressDao
->
checkSessAddress
(
$tempLatLng
,
$currentAddress
);
if
(
$sameFlag
){
if
(
$sameFlag
){
$address
[
'chooseFlag'
]
=
\Our\ApiConst
::
one
;
$address
[
'chooseFlag'
]
=
\Our\ApiConst
::
one
;
$choosedAddressFlag
=
\Our\ApiConst
::
one
;
$choosedAddressFlag
=
\Our\ApiConst
::
one
;
}
else
{
$address
[
'chooseFlag'
]
=
\Our\ApiConst
::
zero
;
$choosedAddressFlag
=
\Our\ApiConst
::
zero
;
}
}
}
}
}
}
...
@@ -233,7 +239,7 @@ class AddressServiceModel extends \Business\AbstractModel {
...
@@ -233,7 +239,7 @@ class AddressServiceModel extends \Business\AbstractModel {
$choosedAddressId
=
$address
[
'addressId'
];
$choosedAddressId
=
$address
[
'addressId'
];
$newCondition
[
'member_id'
]
=
$memberId
;
$newCondition
[
'member_id'
]
=
$memberId
;
$returnAddresses
=
\Our\RedisHelper
::
cachedFunction
(
\Redis\Db8\AddressRedisModel
::
getInstance
(),
array
(
&
$addressDao
,
'selectByWhere'
),
array
(
$newCondition
,
$columns
,
$order
,
$limit
),
3600
,
$newCondition
);
$returnAddresses
=
\Our\RedisHelper
::
cachedFunction
(
\Redis\Db8\AddressRedisModel
::
getInstance
(),
array
(
&
$addressDao
,
'selectByWhere'
),
array
(
$newCondition
,
$columns
,
$order
,
$limit
),
3600
,
$newCondition
);
//print_r($returnAddresses);
$defaultAddressRoute
=
\Our\ApiConst
::
defaultAddressRoute
;
$defaultAddressRoute
=
\Our\ApiConst
::
defaultAddressRoute
;
if
(
$returnAddresses
){
if
(
$returnAddresses
){
$returnAddresses
=
\Our\Common
::
convertUnderline
(
$returnAddresses
);
$returnAddresses
=
\Our\Common
::
convertUnderline
(
$returnAddresses
);
...
@@ -260,11 +266,47 @@ class AddressServiceModel extends \Business\AbstractModel {
...
@@ -260,11 +266,47 @@ class AddressServiceModel extends \Business\AbstractModel {
}
else
{
}
else
{
return
array
(
'returnAddressId'
=>
$choosedAddressId
,
'choosedAddressFlag'
=>
$choosedAddressFlag
);
return
array
(
'returnAddressId'
=>
$choosedAddressId
,
'choosedAddressFlag'
=>
$choosedAddressFlag
);
}
}
}
else
{
if
(
isset
(
$where
[
'default'
])
&&
$where
[
'default'
]){
$choosedAddressFlag
=
\Our\ApiConst
::
zero
;
}
}
}
return
array
(
'returnAddressId'
=>
$choosedAddressId
,
'choosedAddressFlag'
=>
$choosedAddressFlag
,
'addresses'
=>
$returnAddresses
);
return
array
(
'returnAddressId'
=>
$choosedAddressId
,
'choosedAddressFlag'
=>
$choosedAddressFlag
,
'addresses'
=>
$returnAddresses
);
}
}
public
function
getMyCurrentAddressByMemberId
(
$memberId
){
$addressDao
=
\DAO\AddressModel
::
getInstance
();
$columns
=
$this
->
getChoosedAddressColumns
();
$order
=
array
(
'is_default'
=>
'desc'
,
'address_id'
=>
'desc'
);
$limit
=
\Our\ApiConst
::
defaultAddressCount
;
$newCondition
[
'member_id'
]
=
$memberId
;
$returnAddresses
=
\Our\RedisHelper
::
cachedFunction
(
\Redis\Db8\AddressRedisModel
::
getInstance
(),
array
(
&
$addressDao
,
'selectByWhere'
),
array
(
$newCondition
,
$columns
,
$order
,
$limit
),
3600
,
$newCondition
);
//print_r($returnAddresses);
$defaultAddressRoute
=
\Our\ApiConst
::
defaultAddressRoute
;
if
(
$returnAddresses
){
$returnAddresses
=
\Our\Common
::
convertUnderline
(
$returnAddresses
);
if
(
$defaultAddressRoute
){
foreach
(
$returnAddresses
as
&
$tempAdd
){
$tempAdd
[
'cityCode'
]
=
$tempAdd
[
'citycode'
];
unset
(
$tempAdd
[
'citycode'
]);
}
}
$returnAddressList
=
array
();
foreach
(
$returnAddresses
as
$tempAddr
){
$temp
=
array
();
$temp
[
'addressId'
]
=
$tempAddr
[
'addressId'
];
$temp
[
'address'
]
=
$tempAddr
[
'address'
];
$temp
[
'name'
]
=
$tempAddr
[
'name'
];
$temp
[
'tagType'
]
=
$tempAddr
[
'tagType'
];
$returnAddressList
[]
=
$temp
;
}
return
$returnAddressList
;
}
return
false
;
}
/**
/**
* 获取单个收货地址
* 获取单个收货地址
* @param $where
* @param $where
...
...
application/models/Redis/Db4/Abstract.php
View file @
b608d6a6
...
@@ -85,7 +85,9 @@ class AbstractModel extends \Redis\AbstractModel {
...
@@ -85,7 +85,9 @@ class AbstractModel extends \Redis\AbstractModel {
public
function
tableSIsMember
(
$h
,
$value
){
public
function
tableSIsMember
(
$h
,
$value
){
return
$this
->
sIsMember
(
$this
->
calcKey
(
$h
),
$value
);
return
$this
->
sIsMember
(
$this
->
calcKey
(
$h
),
$value
);
}
}
public
function
tableSmembers
(
$key
)
{
return
$this
->
smembers
(
$this
->
calcKey
(
$key
));
}
public
function
tableKeyExists
(
$h
){
public
function
tableKeyExists
(
$h
){
return
$this
->
exists
(
$this
->
calcKey
(
$h
));
return
$this
->
exists
(
$this
->
calcKey
(
$h
));
}
}
...
@@ -99,7 +101,6 @@ class AbstractModel extends \Redis\AbstractModel {
...
@@ -99,7 +101,6 @@ class AbstractModel extends \Redis\AbstractModel {
public
function
tableSRandMember
(
$h
,
$count
=
null
){
public
function
tableSRandMember
(
$h
,
$count
=
null
){
return
$this
->
sRandMember
(
$this
->
calcKey
(
$h
),
$count
);
return
$this
->
sRandMember
(
$this
->
calcKey
(
$h
),
$count
);
}
}
public
function
tableHIncrBy
(
$h
,
$key
,
$keysvalue
){
public
function
tableHIncrBy
(
$h
,
$key
,
$keysvalue
){
return
$this
->
hIncrBy
(
$this
->
calcKey
(
$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