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
efc23116
Commit
efc23116
authored
Jan 09, 2019
by
liuyuzhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
首页及订单库存相关
parent
aae20f62
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
249 additions
and
17 deletions
+249
-17
Home.php
application/controllers/Home.php
+3
-1
OrderConfirmUtil.php
application/library/Order/OrderConfirmUtil.php
+6
-13
Common.php
application/library/Our/Common.php
+20
-1
SecretKeys.php
application/library/Our/SecretKeys.php
+2
-0
GoodsClassService.php
application/models/Business/Goods/GoodsClassService.php
+11
-1
StoreService.php
application/models/Business/Store/StoreService.php
+2
-0
PlatformFirstClass.php
application/models/DAO/GoodsClass/PlatformFirstClass.php
+168
-0
QmStoreClass.php
application/models/DAO/QmStoreClass.php
+2
-0
Error.php
application/models/Error/Error.php
+0
-1
PlatformFirstClassRedis.php
application/models/Redis/Db3/PlatformFirstClassRedis.php
+35
-0
No files found.
application/controllers/Home.php
View file @
efc23116
...
...
@@ -193,6 +193,7 @@ class HomeController extends \Our\Controller_AbstractIndex{
$this
->
success
(
$otherGoods
);
}
/*
public function testMemberAction(){
$memberDao = \DAO\MemberModel::getInstance();
$memberList = $memberDao->getAll();
...
...
@@ -203,6 +204,7 @@ class HomeController extends \Our\Controller_AbstractIndex{
public function writeToFileAction(){
\Business\User\AddressServiceModel::getInstance()->writeToFile();
}
}*/
}
\ No newline at end of file
application/library/Order/OrderConfirmUtil.php
View file @
efc23116
...
...
@@ -49,21 +49,14 @@ class OrderConfirmUtil {
private
$couponCacheFlag
=
false
;
public
function
addOrder
(
$data
,
$memberId
,
$currentAddress
){
$isLock
=
\Lock\RedisLock
::
getInstance
()
->
getLock
(
'addOrder'
);
if
(
$isLock
){
$storeCartData
=
$this
->
checkPostData
(
$data
,
$memberId
,
$currentAddress
);
//return $storeCartData;
if
(
CURRENTVERSION
==
\Our\NameConst
::
versionDefault
){
$storeCartData
=
$this
->
checkDeliveryTypeAndPayway
(
$storeCartData
);
}
else
{
$storeCartData
=
$this
->
checkDeliveryTypeAndPaywayNew
(
$storeCartData
);
}
$result
=
$this
->
saveOrderInfo
(
$storeCartData
);
\Lock\RedisLock
::
getInstance
()
->
releaseLock
(
'addOrder'
);
return
$result
;
$storeCartData
=
$this
->
checkPostData
(
$data
,
$memberId
,
$currentAddress
);
if
(
CURRENTVERSION
==
\Our\NameConst
::
versionDefault
){
$storeCartData
=
$this
->
checkDeliveryTypeAndPayway
(
$storeCartData
);
}
else
{
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
addOrderFrequently
);
$storeCartData
=
$this
->
checkDeliveryTypeAndPaywayNew
(
$storeCartData
);
}
$result
=
$this
->
saveOrderInfo
(
$storeCartData
);
return
$result
;
}
...
...
application/library/Our/Common.php
View file @
efc23116
...
...
@@ -678,7 +678,7 @@ class Common
*/
public
static
function
getIpCity
(
$ip
)
{
$url
=
"http
://ip.taobao.com/service/getIpInfo.php?ip="
.
$ip
;
$url
=
(
self
::
is_https
()
?
'https'
:
'http'
)
.
"
://ip.taobao.com/service/getIpInfo.php?ip="
.
$ip
;
$ip
=
json_decode
(
file_get_contents
(
$url
));
if
((
string
)
$ip
->
code
==
'1'
)
{
return
false
;
...
...
@@ -687,4 +687,23 @@ class Common
return
$data
;
}
public
static
function
getAddressByLatLng
(
$lat
,
$lng
){
$key
=
\Our\SecretKeys
::
amapKey
;
$url
=
(
self
::
is_https
()
?
'https'
:
'http'
)
.
'://restapi.amap.com/v3/geocode/regeo?key='
.
$key
.
'&location='
.
$lng
.
','
.
$lat
.
'&poitype=&radius=10&extensions=all&batch=false&roadlevel=0'
;
$address
=
json_decode
(
file_get_contents
(
$url
));
if
(
$address
->
status
){
return
json_decode
(
json_encode
(
$address
->
regeocode
->
addressComponent
),
true
);
}
return
false
;
}
public
static
function
getCityCodeByLatLng
(
$lat
,
$lng
){
$address
=
self
::
getAddressByLatLng
(
$lat
,
$lng
);
if
(
$address
&&
isset
(
$address
[
'citycode'
])){
return
$address
[
'citycode'
];
}
return
false
;
}
}
application/library/Our/SecretKeys.php
View file @
efc23116
...
...
@@ -54,6 +54,8 @@ class SecretKeys {
const
pushKey
=
'37e9a38cf2983bcdf885e5fd'
;
const
pushSecret
=
'c59868c235bc7ccbe865f9d9'
;
const
amapKey
=
'51540038b13949411b93f05fd94da971'
;
}
...
...
application/models/Business/Goods/GoodsClassService.php
View file @
efc23116
...
...
@@ -64,7 +64,9 @@ class GoodsClassServiceModel extends \Business\AbstractModel{
public
function
getPlatformGoodsClass
(
$where
){
//验证参数
$addressDao
=
\DAO\AddressModel
::
getInstance
();
/*$addressDao = \DAO\AddressModel::getInstance();
$validFlag = $addressDao->getValidAddress($where);
if(!$validFlag){
\Error\ErrorModel::throwException($addressDao->errorCode);
...
...
@@ -86,6 +88,8 @@ class GoodsClassServiceModel extends \Business\AbstractModel{
if($serviceParentClassIds){
$classIds = array_merge($serviceParentClassIds,$classIds);
}
var_dump($classIds);*/
/*
//获取可快递店铺对应分类
$expressClassIds = $this->getExpressStoreClasses($where);
...
...
@@ -93,6 +97,12 @@ class GoodsClassServiceModel extends \Business\AbstractModel{
$classIds = array_merge($expressClassIds,$classIds);
}
*/
$classIds
=
array
();
$platformFirstClassDao
=
\DAO\GoodsClass\PlatformFirstClassModel
::
getInstance
();
$firstClassList
=
\Our\RedisHelper
::
cachedFunction
(
\Redis\Db3\PlatformFirstClassRedisModel
::
getInstance
(),
array
(
&
$platformFirstClassDao
,
'getList'
),
array
(),
\Our\ApiConst
::
oneHour
,
array
());
if
(
$firstClassList
){
$classIds
=
array_column
(
$firstClassList
,
'gc_id'
);
}
$classIdKeys
=
array_flip
(
$classIds
);
$goodsClassDao
=
\DAO\GoodsClassModel
::
getInstance
();
$parentClasses
=
$goodsClassDao
->
getParentClasses
();
...
...
application/models/Business/Store/StoreService.php
View file @
efc23116
...
...
@@ -1176,6 +1176,8 @@ class StoreServiceModel extends \Business\AbstractModel{
$storeDao
=
\DAO\StoreModel
::
getInstance
();
$storeDao
->
delNearbyStoresCache
(
$cityCode
);
$storeDao
->
delStoresCacheByCityCode
(
$cityCode
);
$platformFirstClassDao
=
\DAO\GoodsClass\PlatformFirstClassModel
::
getInstance
();
\Our\RedisHelper
::
delCachedFunction
(
\Redis\Db3\PlatformFirstClassRedisModel
::
getInstance
(),
array
(
&
$platformFirstClassDao
,
'getList'
),
array
(),
array
());
return
true
;
}
...
...
application/models/DAO/GoodsClass/PlatformFirstClass.php
0 → 100644
View file @
efc23116
<?php
namespace
DAO\GoodsClass
;
/**
* User: liuyuzhen
* Date: 2018/7/18
* Time: 10:58
* Description:
*/
class
PlatformFirstClassModel
extends
\DAO\AbstractModel
{
/**
* 表名
*
* @var string
*/
protected
$_tableName
=
'han_platform_first_class'
;
/**
* 主键
*
* @var string
*/
protected
$_primaryKey
=
'gc_parent_id'
;
public
function
init
(){
}
public
function
findByWhere
(
$where
){
$this
->
setDb
(
\Our\DbNameConst
::
salveDBConnectName
);
$address
=
$this
->
db
->
from
(
$this
->
_tableName
)
->
where
(
$where
)
->
fetchOne
();
return
$address
;
}
public
function
getList
(
$where
,
$field
=
\Our\NameConst
::
allField
){
$this
->
setDb
(
$this
->
dbName
);
$result
=
$this
->
db
->
select
(
$field
)
->
from
(
$this
->
_tableName
)
->
where
(
$where
)
->
fetchAll
();
return
$result
;
}
public
function
getStoreOnlineGoodsClassesByGcIdFromCache
(
$gcId
,
$storeId
,
$field
=
\Our\NameConst
::
allField
){
$gcIds
=
\Our\RedisHelper
::
cachedFunction
(
\Redis\Db6\StoreOnlineGoodsClassRedisModel
::
getInstance
(),
array
(
&
$this
,
'getStoreOnlineGoodsClassesByGcId'
),
array
(
$gcId
,
$storeId
,
$field
),
\Our\ApiConst
::
oneDaySecond
,
array
(
$storeId
));
return
$gcIds
;
}
public
function
getStoreOnlineGoodsClassesByGcId
(
$gcId
,
$storeId
,
$field
=
\Our\NameConst
::
allField
){
$where
[
'gc_id_1'
]
=
$gcId
;
$where
[
'store_id'
]
=
$storeId
;
$list
=
$this
->
getList
(
$where
);
if
(
$list
){
$platThirdGcIds
=
array
();
$storeThirdGcIds
=
array
();
$secondGcIds
=
array_unique
(
array_column
(
$list
,
'gc_id_2'
));
$treeGcIds
=
array
();
foreach
(
$list
as
$temp
){
if
(
$temp
[
'gc_from'
]
==
\Our\ApiConst
::
zero
){
$platThirdGcIds
[]
=
$temp
[
'gc_id_3'
];
}
else
{
$storeThirdGcIds
[]
=
$temp
[
'gc_id_3'
];
}
if
(
!
(
isset
(
$treeGcIds
[
$temp
[
'gc_id_2'
]][
$temp
[
'gc_from'
]])
&&
in_array
(
$temp
[
'gc_id_3'
],
$treeGcIds
[
$temp
[
'gc_id_2'
]][
$temp
[
'gc_from'
]]))){
$treeGcIds
[
$temp
[
'gc_id_2'
]][
$temp
[
'gc_from'
]][]
=
$temp
[
'gc_id_3'
];
}
}
$platThirdGcIds
=
array_unique
(
$platThirdGcIds
);
$storeThirdGcIds
=
array_unique
(
$storeThirdGcIds
);
return
array
(
'secondGcIds'
=>
$secondGcIds
,
'treeGcIds'
=>
$treeGcIds
,
'platThirdGcIds'
=>
$platThirdGcIds
,
'storeThirdGcIds'
=>
$storeThirdGcIds
);
}
return
false
;
}
/**
* 检查获取店铺一级在售分类传参是否正确
*/
public
function
checkStoreTopClasses
(
$data
){
if
(
!
isset
(
$data
[
'storeId'
])){
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
emptyStoreIdForOnlineTopClass
);
}
}
/**
* 检查获取店铺下级在售分类及广告传参是否正确
*/
public
function
checkStoreChildrenClasses
(
$data
){
if
(
!
isset
(
$data
[
'storeId'
])){
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
emptyStoreIdForOnlineChildrenClass
);
}
if
(
!
isset
(
$data
[
'gcId'
])){
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
emtpyGcIdForOnlineChildrenClass
);
}
}
/**
* 商品详情发生改变存如缓存
* @param $goodsCommon goodsCommon详情
* @param int $type 操作类型(1:加,0:减)
* @return bool
*/
public
function
addGoodsToGoodsClassCache
(
$goodsCommon
,
$type
=
\Our\ApiConst
::
plus
){
if
(
!
$goodsCommon
){
return
false
;
}
$goodsClass
[
'gc_id_1'
]
=
$goodsCommon
[
'gc_id_1'
];
$goodsClass
[
'gc_id_2'
]
=
$goodsCommon
[
'gc_id_2'
];
$goodsClass
[
'gc_id_3'
]
=
$goodsCommon
[
'gc_id_3'
];
$goodsClass
[
'store_id'
]
=
$goodsCommon
[
'store_id'
];
$goodsClass
[
'gc_from'
]
=
\Our\ApiConst
::
zero
;
if
(
$goodsClass
[
'gc_id_3'
]){
$this
->
addChangedGoodsClass
(
serialize
(
$goodsClass
),
$type
);
}
if
(
$goodsCommon
[
'goods_class_t_id'
]){
$goodsClass
[
'gc_id_3'
]
=
$goodsCommon
[
'goods_class_t_id'
];
$goodsClass
[
'gc_from'
]
=
\Our\ApiConst
::
one
;
$this
->
addChangedGoodsClass
(
serialize
(
$goodsClass
),
$type
);
}
return
true
;
}
public
function
addChangedGoodsClass
(
$goodsClass
,
$type
=
\Our\ApiConst
::
plus
){
$key
=
'changedAddGoodsClass'
;
if
(
$type
==
\Our\ApiConst
::
minus
){
$key
=
'changedMinusGoodsClass'
;
}
$storeOnlineClassRedisModel
=
\Redis\Db6\StoreOnlineGoodsClassRedisModel
::
getInstance
();
$storeOnlineClassRedisModel
->
tableLPush
(
$key
,
$goodsClass
);
}
public
function
getChangedGoodsClass
(
$type
=
\Our\ApiConst
::
plus
){
$key
=
'changedAddGoodsClass'
;
if
(
$type
==
\Our\ApiConst
::
minus
){
$key
=
'changedMinusGoodsClass'
;
}
$storeOnlineClassRedisModel
=
\Redis\Db6\StoreOnlineGoodsClassRedisModel
::
getInstance
();
return
$storeOnlineClassRedisModel
->
tableLPop
(
$key
);
}
/**
* 获取更改商品
* @param $start 记录开始条数
* @param $end 记录结束条数
* @return \Redis\mix
*/
public
function
getChangedGoodsClasses
(
$start
,
$end
,
$type
=
\Our\ApiConst
::
plus
){
$key
=
'changedAddGoodsClass'
;
if
(
$type
==
\Our\ApiConst
::
minus
){
$key
=
'changedMinusGoodsClass'
;
}
$storeOnlineClassRedisModel
=
\Redis\Db6\StoreOnlineGoodsClassRedisModel
::
getInstance
();
return
$storeOnlineClassRedisModel
->
tableLRange
(
$key
,
$start
,
$end
);
}
/**
* 类实例
*/
private
static
$_instance
=
null
;
/**
* 获取类实例
*/
public
static
function
getInstance
(
$dbName
=
\Our\DbNameConst
::
salveDBConnectName
)
{
if
(
!
(
self
::
$_instance
instanceof
self
))
{
self
::
$_instance
=
new
self
(
$dbName
);
}
return
self
::
$_instance
;
}
}
\ No newline at end of file
application/models/DAO/QmStoreClass.php
View file @
efc23116
...
...
@@ -123,6 +123,8 @@ class QmStoreClassModel extends \DAO\AbstractModel{
if
(
$storeId
){
\Our\RedisHelper
::
delCachedFunction
(
\Redis\Db6\QmStoreClassRedisModel
::
getInstance
(),
array
(
&
$this
,
'getStoreSignClasses'
),
array
(),
array
(
'store'
.
$storeId
));
}
$platformFirstClassDao
=
\DAO\GoodsClass\PlatformFirstClassModel
::
getInstance
();
\Our\RedisHelper
::
delCachedFunction
(
\Redis\Db3\PlatformFirstClassRedisModel
::
getInstance
(),
array
(
&
$platformFirstClassDao
,
'getList'
),
array
(),
array
());
}
/**
...
...
application/models/Error/Error.php
View file @
efc23116
...
...
@@ -15,7 +15,6 @@ class ErrorModel {
* @throws \Exception
*/
public
static
function
throwException
(
$code
,
$message
=
null
)
{
\Lock\RedisLock
::
getInstance
()
->
releaseLock
(
'addOrder'
);
if
(
!
$message
)
{
$codeConfig
=
\Error\CodeConfigModel
::
getCodeConfig
();
if
(
empty
(
$codeConfig
[
$code
]))
{
...
...
application/models/Redis/Db3/PlatformFirstClassRedis.php
0 → 100644
View file @
efc23116
<?php
namespace
Redis\Db3
;
/**
* 平台在经营一级分类
* User: liuyuzhen
* Date: 2019/01/08
* Time: 15:36
* Description:
*/
class
PlatformFirstClassRedisModel
extends
\Redis\Db3\AbstractModel
{
/**
* 表名
*
* @var string
*/
protected
$_tableName
=
'han_platform_first_class'
;
/**
* 类实例
*
*/
private
static
$_instance
=
null
;
/**
* 获取类实例
*/
public
static
function
getInstance
()
{
if
(
!
(
self
::
$_instance
instanceof
self
))
{
self
::
$_instance
=
new
self
();
}
return
self
::
$_instance
;
}
}
\ No newline at end of file
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