Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
goods
Project
Project
Details
Activity
Releases
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
bp
goods
Commits
f73c5222
Commit
f73c5222
authored
Jun 17, 2021
by
jianghaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:set
parent
fc318f70
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
749 additions
and
22 deletions
+749
-22
Code.php
application/exception/custom/Code.php
+1
-0
ShopException.php
application/exception/custom/ShopException.php
+24
-0
helper.php
application/library/helper.php
+1
-1
Distribution.php
application/models/distribution/mysql/Distribution.php
+66
-0
DistributionGoods.php
application/models/distribution/mysql/DistributionGoods.php
+67
-0
Distributor.php
application/models/distribution/mysql/Distributor.php
+66
-0
SubShop.php
application/models/shop/mysql/SubShop.php
+3
-2
Distribution.php
...ication/modules/Distribution/controllers/Distribution.php
+25
-0
Shop.php
application/modules/Shop/controllers/Shop.php
+26
-18
DistributionGoodsService.php
...cation/services/distribution/DistributionGoodsService.php
+32
-0
DistributionService.php
application/services/distribution/DistributionService.php
+54
-0
DistributorService.php
application/services/distribution/DistributorService.php
+176
-0
ShopService.php
application/services/shop/ShopService.php
+175
-0
SubShopService.php
application/services/shop/SubShopService.php
+32
-0
application.ini
conf/application.ini
+1
-1
No files found.
application/exception/custom/Code.php
View file @
f73c5222
...
@@ -14,4 +14,5 @@ class Code
...
@@ -14,4 +14,5 @@ class Code
const
PARAM
=
101000
;
const
PARAM
=
101000
;
const
SIGN
=
102000
;
const
SIGN
=
102000
;
const
GOODS
=
108000
;
const
GOODS
=
108000
;
const
SHOP
=
109000
;
}
}
\ No newline at end of file
application/exception/custom/ShopException.php
0 → 100644
View file @
f73c5222
<?php
namespace
App\Exception\custom
;
use
App\Exception\BaseException
;
class
ShopException
extends
BaseException
{
protected
$base_code
=
Code
::
SHOP
;
protected
$cus
=
[
0
=>
'生活号不能为空'
,
1
=>
'手机号不能为空'
,
2
=>
'手机号格式不正确'
,
3
=>
'门店名称不能为空'
,
4
=>
'标题不合法,涉及敏感词'
,
5
=>
'门店创建失败'
,
6
=>
'门店名称已存在'
,
7
=>
'手机号已存在'
,
8
=>
'门店名称不能大于20个字'
,
];
}
\ No newline at end of file
application/library/helper.php
View file @
f73c5222
...
@@ -15,7 +15,7 @@ if (!function_exists('config')) {
...
@@ -15,7 +15,7 @@ if (!function_exists('config')) {
*/
*/
function
config
(
$file
,
$param
=
''
){
function
config
(
$file
,
$param
=
''
){
if
(
empty
(
$file
)
||
!
file_exists
(
ROOT_PATH
.
"/yaconf/"
.
$file
.
".ini"
)){
if
(
empty
(
$file
)
||
!
file_exists
(
ROOT_PATH
.
"/yaconf/"
.
$file
.
".ini"
)){
return
""
;
//
return "";
}
}
$env
=
Application
::
app
()
->
environ
()
??
"dev"
;
$env
=
Application
::
app
()
->
environ
()
??
"dev"
;
...
...
application/models/distribution/mysql/Distribution.php
0 → 100644
View file @
f73c5222
<?php
namespace
App\Models\distribution\mysql
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
Distribution
extends
MysqlBase
{
const
TABLE_NAME
=
'distribution'
;
const
CONFIG_INDEX
=
'distribution'
;
const
PRIMARY_KEY
=
'id'
;
public
static
function
getRecord
(
$where
,
$colums
=
[])
{
if
(
empty
(
$colums
))
{
$colums
=
'*'
;
}
return
self
::
get
(
$colums
,
$where
);
}
public
static
function
getRecordMaster
(
$where
,
$colums
=
[])
{
if
(
empty
(
$colums
))
{
$colums
=
'*'
;
}
return
self
::
selectMaster
(
$colums
,
$where
);
}
public
static
function
insertRecord
(
$colums
)
{
return
self
::
insert
(
$colums
);
}
public
static
function
updateRecord
(
$colums
,
$where
)
{
return
self
::
update
(
$colums
,
$where
);
}
public
static
function
save
(
$data
,
$where
=
[])
{
if
(
empty
(
$where
))
{
return
self
::
insert
(
$data
);
}
return
self
::
update
(
$data
,
$where
);
}
public
static
function
deleteRecord
(
$where
)
{
return
self
::
delete
(
$where
);
}
public
static
function
getRecords
(
$where
,
$colums
=
[])
{
if
(
empty
(
$colums
))
{
$colums
=
'*'
;
}
return
self
::
select
(
$colums
,
$where
);
}
public
static
function
getCount
(
$where
)
{
return
self
::
count
(
$where
);
}
}
application/models/distribution/mysql/DistributionGoods.php
0 → 100644
View file @
f73c5222
<?php
namespace
App\Models\shop\mysql
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
SubShop
extends
MysqlBase
{
const
TABLE_NAME
=
'sub_shop'
;
const
CONFIG_INDEX
=
'goods'
;
const
PRIMARY_KEY
=
'stores_id'
;
public
static
function
getRecord
(
$where
,
$colums
=
[])
{
if
(
empty
(
$colums
))
{
$colums
=
'*'
;
}
return
self
::
get
(
$colums
,
$where
);
}
public
static
function
getRecordMaster
(
$where
,
$colums
=
[])
{
if
(
empty
(
$colums
))
{
$colums
=
'*'
;
}
return
self
::
selectMaster
(
$colums
,
$where
);
}
public
static
function
insertRecord
(
$colums
)
{
$options
[
'rowCount'
]
=
true
;
return
self
::
insert
(
$colums
,
$options
);
}
public
static
function
updateRecord
(
$colums
,
$where
)
{
return
self
::
update
(
$colums
,
$where
);
}
public
static
function
save
(
$data
,
$where
=
[])
{
if
(
empty
(
$where
))
{
return
self
::
insert
(
$data
);
}
return
self
::
update
(
$data
,
$where
);
}
public
static
function
deleteRecord
(
$where
)
{
return
self
::
delete
(
$where
);
}
public
static
function
getRecords
(
$where
,
$colums
=
[])
{
if
(
empty
(
$colums
))
{
$colums
=
'*'
;
}
return
self
::
select
(
$colums
,
$where
);
}
public
static
function
getCount
(
$where
)
{
return
self
::
count
(
$where
);
}
}
application/models/distribution/mysql/Distributor.php
0 → 100644
View file @
f73c5222
<?php
namespace
App\Models\shop\mysql
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
Distributor
extends
MysqlBase
{
const
TABLE_NAME
=
'shop'
;
const
CONFIG_INDEX
=
'goods'
;
const
PRIMARY_KEY
=
'shop_id'
;
public
static
function
getRecord
(
$where
,
$colums
=
[])
{
if
(
empty
(
$colums
))
{
$colums
=
'*'
;
}
return
self
::
get
(
$colums
,
$where
);
}
public
static
function
getRecordMaster
(
$where
,
$colums
=
[])
{
if
(
empty
(
$colums
))
{
$colums
=
'*'
;
}
return
self
::
selectMaster
(
$colums
,
$where
);
}
public
static
function
insertRecord
(
$colums
)
{
return
self
::
insert
(
$colums
);
}
public
static
function
updateRecord
(
$colums
,
$where
)
{
return
self
::
update
(
$colums
,
$where
);
}
public
static
function
save
(
$data
,
$where
=
[])
{
if
(
empty
(
$where
))
{
return
self
::
insert
(
$data
);
}
return
self
::
update
(
$data
,
$where
);
}
public
static
function
deleteRecord
(
$where
)
{
return
self
::
delete
(
$where
);
}
public
static
function
getRecords
(
$where
,
$colums
=
[])
{
if
(
empty
(
$colums
))
{
$colums
=
'*'
;
}
return
self
::
select
(
$colums
,
$where
);
}
public
static
function
getCount
(
$where
)
{
return
self
::
count
(
$where
);
}
}
application/models/shop/mysql/SubShop.php
View file @
f73c5222
...
@@ -18,7 +18,7 @@ class SubShop extends MysqlBase
...
@@ -18,7 +18,7 @@ class SubShop extends MysqlBase
if
(
empty
(
$colums
))
{
if
(
empty
(
$colums
))
{
$colums
=
'*'
;
$colums
=
'*'
;
}
}
self
::
get
(
$colums
,
$where
);
return
self
::
get
(
$colums
,
$where
);
}
}
public
static
function
getRecordMaster
(
$where
,
$colums
=
[])
public
static
function
getRecordMaster
(
$where
,
$colums
=
[])
{
{
...
@@ -30,7 +30,8 @@ class SubShop extends MysqlBase
...
@@ -30,7 +30,8 @@ class SubShop extends MysqlBase
public
static
function
insertRecord
(
$colums
)
public
static
function
insertRecord
(
$colums
)
{
{
return
self
::
insert
(
$colums
);
$options
[
'rowCount'
]
=
true
;
return
self
::
insert
(
$colums
,
$options
);
}
}
public
static
function
updateRecord
(
$colums
,
$where
)
public
static
function
updateRecord
(
$colums
,
$where
)
...
...
application/modules/Distribution/controllers/Distribution.php
0 → 100644
View file @
f73c5222
<?php
use
App\Base\Base
;
use
App\Services\distribution\DistributionService
;
use
App\Exception\custom\ShopException
;
class
DistributionController
extends
Base
{
public
function
get_distribution_listAction
()
{
$params
=
$this
->
getRequest
()
->
getRequest
();
print_r
(
$params
);
die
();
$srt
=
DistributionService
::
addDistribution
(
$params
);
print_r
(
$srt
);
}
}
\ No newline at end of file
application/modules/Shop/controllers/Shop.php
View file @
f73c5222
<?php
<?php
use
App\Base\Base
;
use
App\Base\Base
;
use
App\Models\shop\mysql\Shop
;
use
App\Services\shop\ShopService
;
use
App\Models\shop\mysql\SubShop
;
use
App\Exception\custom\ShopException
;
// use Validate\ShopValidate;
// use App\Exception\custom\ShopException;
class
ShopController
extends
Base
class
ShopController
extends
Base
{
{
public
function
get_shop_listAction
()
/**
* 创建店铺
*
*/
public
function
add_shopAction
()
{
{
//$params = $this->getRequest()->getRequest();
$params
=
$this
->
getRequest
()
->
getRequest
();
$shop
=
ShopService
::
addShop
(
$params
);
if
(
!
empty
(
$shop
))
{
$where
[
'life_account_id'
]
=
0
;
$this
->
success
();
}
else
{
$subShop
=
SubShop
::
getRecord
(
$where
);
throw
new
ShopException
([
'cus'
=>
5
]);
}
print_r
(
$subShop
);
}
/**
* 门店列表
*
*/
public
function
get_shop_listAction
()
{
$params
=
$this
->
getRequest
()
->
getRequest
();
$subShopList
=
ShopService
::
getShopList
(
$params
);
$this
->
success
([
'result'
=>
$subShopList
]);
}
}
}
}
\ No newline at end of file
application/services/distribution/DistributionGoodsService.php
0 → 100644
View file @
f73c5222
<?php
namespace
App\Services\goods
;
use
App\Models\goods\mysql\Category
;
class
CategoryService
{
public
static
function
getCategoryList
()
{
//todo::加上redis
$allCaregoryList
=
Category
::
getRecordList
([],
[
'category_id'
,
'parent_category_id'
,
'name'
,
'level'
]);
$data
=
[];
if
(
!
empty
(
$allCaregoryList
))
{
foreach
(
$allCaregoryList
as
$caregory
)
{
if
(
$caregory
[
"level"
]
==
Category
::
LEVEL_1
)
{
$data
[
"level_1"
][]
=
[
"category_id"
=>
$caregory
[
"category_id"
],
"name"
=>
$caregory
[
"name"
]
];
}
if
(
$caregory
[
"level"
]
==
Category
::
LEVEL_2
)
{
$data
[
"level_2"
][
$caregory
[
"parent_category_id"
]][]
=
[
"category_id"
=>
$caregory
[
"category_id"
],
"name"
=>
$caregory
[
"name"
]
];
}
}
}
return
$data
;
}
}
\ No newline at end of file
application/services/distribution/DistributionService.php
0 → 100644
View file @
f73c5222
<?php
namespace
App\Services\distribution
;
use
App\Models\shop\mysql\Distribution
;
use
Api\PhpUtils\Validate\Validate
;
use
Api\PhpServices\Idgen\Idgen
;
class
DistributionService
{
public
static
function
addDistribution
(
$params
)
{
$params
=
[
];
Distribution
::
insertRecord
(
$params
);
}
public
static
function
getDistributionList
(
$params
)
{
}
/**
* 通过发号器拿 id (非雪花)
* number,获取店铺shop_id用生活号id后两位,商品相关的这里是shop_id的后两位
* @param $number
* @param $type
* @param int $count
* @return array|mixed
*/
public
static
function
getIdgenId
(
$number
,
$type
,
$count
=
1
)
{
$res
=
Idgen
::
get
(
appConfig
(
'idgen.partner'
),
appConfig
(
'idgen.key'
),
[],
[[
"type"
=>
$type
,
'number'
=>
(
int
)
$number
,
"count"
=>
$count
]]);
return
$res
[
'id_datetime'
][
$type
]
??
[];
}
public
static
function
getSnowIdgenId
(
$type
,
$count
=
1
)
{
$res
=
Idgen
::
get
(
appConfig
(
'idgen.partner'
),
appConfig
(
'idgen.key'
),
[[
"type"
=>
$type
,
"count"
=>
$count
]],
[]);
return
$res
[
'id_snow'
][
$type
]
??
[];
}
}
\ No newline at end of file
application/services/distribution/DistributorService.php
0 → 100644
View file @
f73c5222
<?php
namespace
App\Services\shop
;
use
App\Models\shop\mysql\Shop
;
use
App\Models\shop\mysql\SubShop
;
use
Api\PhpUtils\Validate\Validate
;
use
Api\PhpServices\Idgen\Idgen
;
// use Validate\ShopValidate;
use
App\Exception\custom\ShopException
;
use
Api\PhpServices\Sensitive\Sensitive
;
class
DistributorService
{
public
static
function
addShop
(
$params
)
{
$life_account_id
=
!
empty
(
$params
[
'life_account_id'
])
?
$params
[
'life_account_id'
]
:
''
;
$phone
=
!
empty
(
$params
[
'phone'
])
?
$params
[
'phone'
]
:
''
;
$shop_id
=
!
empty
(
$params
[
'shop_id'
])
?
$params
[
'shop_id'
]
:
''
;
$name
=
!
empty
(
$params
[
'name'
])
?
$params
[
'name'
]
:
''
;
$address_lng
=
!
empty
(
$params
[
'address_lng'
])
?
$params
[
'address_lng'
]
:
''
;
$address_lat
=
!
empty
(
$params
[
'address_lat'
])
?
$params
[
'address_lat'
]
:
''
;
$address
=
!
empty
(
$params
[
'address'
])
?
$params
[
'address'
]
:
''
;
if
(
empty
(
$life_account_id
))
{
throw
new
ShopException
([
'cus'
=>
0
]);
}
if
(
empty
(
$phone
))
{
throw
new
ShopException
([
'cus'
=>
1
]);
}
// $is_mobile = ( new Validate)->isMobile($phone);
// if (empty($is_mobile)) {
// throw new ShopException(['cus'=>2]);
// }
if
(
empty
(
$name
))
{
throw
new
ShopException
([
'cus'
=>
3
]);
}
if
(
self
::
utf8Strlen
(
$name
)
>
20
)
{
throw
new
ShopException
([
'cus'
=>
8
]);
}
$detectParams
=
[
'businessId'
=>
1
,
'text'
=>
!
empty
(
$name
)
?
$name
:
''
,
'scene'
=>
1
,
];
$sensitive
=
(
new
Sensitive
)
->
detect
(
$detectParams
);
if
(
!
empty
(
$sensitive
[
'data'
]))
{
throw
new
ShopException
([
'cus'
=>
4
]);
}
//判断店铺重复
if
(
!
self
::
isName
(
$name
))
{
throw
new
ShopException
([
'cus'
=>
6
]);
}
//判断手机号重复
if
(
!
self
::
isPhone
(
$phone
))
{
throw
new
ShopException
([
'cus'
=>
7
]);
}
$res
=
self
::
getIdgenId
(
1
,
'goods'
,
$count
=
1
);
$stores_id
=
!
empty
(
$res
[
0
])
?
$res
[
0
]
:
''
;
$colums
=
[
'stores_id'
=>
$stores_id
,
'life_account_id'
=>
$life_account_id
,
'shop_id'
=>
$shop_id
,
'name'
=>
$name
,
'address_lng'
=>
$address_lng
,
'address_lat'
=>
$address_lat
,
'address'
=>
$address
,
'phone'
=>
$phone
,
'create_time'
=>
date
(
"Y-m-d H:i:s"
),
];
$subShop
=
SubShop
::
insertRecord
(
$colums
);
return
$subShop
;
}
public
static
function
getShopList
(
$params
)
{
$life_account_id
=
!
empty
(
$params
[
'life_account_id'
])
?
$params
[
'life_account_id'
]
:
''
;
$phone
=
!
empty
(
$params
[
'phone'
])
?
$params
[
'phone'
]
:
''
;
$shop_id
=
!
empty
(
$params
[
'shop_id'
])
?
$params
[
'shop_id'
]
:
''
;
$name
=
!
empty
(
$params
[
'name'
])
?
$params
[
'name'
]
:
''
;
$address_lng
=
!
empty
(
$params
[
'address_lng'
])
?
$params
[
'address_lng'
]
:
''
;
$address_lat
=
!
empty
(
$params
[
'address_lat'
])
?
$params
[
'address_lat'
]
:
''
;
$address
=
!
empty
(
$params
[
'address'
])
?
$params
[
'address'
]
:
''
;
$where
[
'life_account_id'
]
=
$life_account_id
;
$where
[
'ORDER'
]
=
[
"create_time"
=>
"DESC"
];
$subShopList
=
SubShop
::
getRecords
(
$where
);
return
$subShopList
;
}
/**
* 门店名称是否重复
*
*/
public
static
function
isName
(
$name
=
''
)
{
if
(
empty
(
$name
))
{
return
false
;
}
$colums
=
[
'name'
=>
$name
];
$subShop
=
SubShop
::
getRecord
(
$colums
);
if
(
!
empty
(
$subShop
))
{
return
false
;
}
return
true
;
}
/**
* 门店手机号是否重复
*
*/
public
static
function
isPhone
(
$phone
=
''
)
{
if
(
empty
(
$phone
))
{
return
false
;
}
$colums
=
[
'phone'
=>
$phone
];
$subShop
=
SubShop
::
getRecord
(
$colums
);
if
(
!
empty
(
$subShop
))
{
return
false
;
}
return
true
;
}
/**
*判断长度
*
*/
public
static
function
utf8Strlen
(
$string
=
null
)
{
// 将字符串分解为单元
preg_match_all
(
"/./us"
,
$string
,
$match
);
// // 返回单元个数
return
count
(
$match
[
0
]);
}
/**
* 通过发号器拿 id (非雪花)
* number,获取店铺shop_id用生活号id后两位,商品相关的这里是shop_id的后两位
* @param $number
* @param $type
* @param int $count
* @return array|mixed
*/
public
static
function
getIdgenId
(
$number
,
$type
,
$count
=
1
)
{
$res
=
Idgen
::
get
(
appConfig
(
'idgen.partner'
),
appConfig
(
'idgen.key'
),
[],
[[
"type"
=>
$type
,
'number'
=>
(
int
)
$number
,
"count"
=>
$count
]]);
return
$res
[
'id_datetime'
][
$type
]
??
[];
}
public
static
function
getSnowIdgenId
(
$type
,
$count
=
1
)
{
$res
=
Idgen
::
get
(
appConfig
(
'idgen.partner'
),
appConfig
(
'idgen.key'
),
[[
"type"
=>
$type
,
"count"
=>
$count
]],
[]);
return
$res
[
'id_snow'
][
$type
]
??
[];
}
}
\ No newline at end of file
application/services/shop/ShopService.php
0 → 100644
View file @
f73c5222
<?php
namespace
App\Services\shop
;
use
App\Models\shop\mysql\Shop
;
use
App\Models\shop\mysql\SubShop
;
use
Api\PhpUtils\Validate\Validate
;
use
Api\PhpServices\Idgen\Idgen
;
// use Validate\ShopValidate;
use
App\Exception\custom\ShopException
;
use
Api\PhpServices\Sensitive\Sensitive
;
class
ShopService
{
public
static
function
addShop
(
$params
)
{
$life_account_id
=
!
empty
(
$params
[
'life_account_id'
])
?
$params
[
'life_account_id'
]
:
''
;
$phone
=
!
empty
(
$params
[
'phone'
])
?
$params
[
'phone'
]
:
''
;
$shop_id
=
!
empty
(
$params
[
'shop_id'
])
?
$params
[
'shop_id'
]
:
''
;
$name
=
!
empty
(
$params
[
'name'
])
?
$params
[
'name'
]
:
''
;
$address_lng
=
!
empty
(
$params
[
'address_lng'
])
?
$params
[
'address_lng'
]
:
''
;
$address_lat
=
!
empty
(
$params
[
'address_lat'
])
?
$params
[
'address_lat'
]
:
''
;
$address
=
!
empty
(
$params
[
'address'
])
?
$params
[
'address'
]
:
''
;
if
(
empty
(
$life_account_id
))
{
throw
new
ShopException
([
'cus'
=>
0
]);
}
if
(
empty
(
$phone
))
{
throw
new
ShopException
([
'cus'
=>
1
]);
}
// $is_mobile = ( new Validate)->isMobile($phone);
// if (empty($is_mobile)) {
// throw new ShopException(['cus'=>2]);
// }
if
(
empty
(
$name
))
{
throw
new
ShopException
([
'cus'
=>
3
]);
}
if
(
self
::
utf8Strlen
(
$name
)
>
20
)
{
throw
new
ShopException
([
'cus'
=>
8
]);
}
$detectParams
=
[
'businessId'
=>
1
,
'text'
=>
!
empty
(
$name
)
?
$name
:
''
,
'scene'
=>
1
,
];
$sensitive
=
(
new
Sensitive
)
->
detect
(
$detectParams
);
if
(
!
empty
(
$sensitive
[
'data'
]))
{
throw
new
ShopException
([
'cus'
=>
4
]);
}
//判断店铺重复
if
(
!
self
::
isName
(
$name
))
{
throw
new
ShopException
([
'cus'
=>
6
]);
}
//判断手机号重复
if
(
!
self
::
isPhone
(
$phone
))
{
throw
new
ShopException
([
'cus'
=>
7
]);
}
$res
=
self
::
getIdgenId
(
1
,
'goods'
,
$count
=
1
);
$stores_id
=
!
empty
(
$res
[
0
])
?
$res
[
0
]
:
''
;
$colums
=
[
'stores_id'
=>
$stores_id
,
'life_account_id'
=>
$life_account_id
,
'shop_id'
=>
$shop_id
,
'name'
=>
$name
,
'address_lng'
=>
$address_lng
,
'address_lat'
=>
$address_lat
,
'address'
=>
$address
,
'phone'
=>
$phone
,
'create_time'
=>
date
(
"Y-m-d H:i:s"
),
];
$subShop
=
SubShop
::
insertRecord
(
$colums
);
return
$subShop
;
}
public
static
function
getShopList
(
$params
)
{
$life_account_id
=
!
empty
(
$params
[
'life_account_id'
])
?
$params
[
'life_account_id'
]
:
''
;
$phone
=
!
empty
(
$params
[
'phone'
])
?
$params
[
'phone'
]
:
''
;
$shop_id
=
!
empty
(
$params
[
'shop_id'
])
?
$params
[
'shop_id'
]
:
''
;
$name
=
!
empty
(
$params
[
'name'
])
?
$params
[
'name'
]
:
''
;
$address_lng
=
!
empty
(
$params
[
'address_lng'
])
?
$params
[
'address_lng'
]
:
''
;
$address_lat
=
!
empty
(
$params
[
'address_lat'
])
?
$params
[
'address_lat'
]
:
''
;
$address
=
!
empty
(
$params
[
'address'
])
?
$params
[
'address'
]
:
''
;
$where
[
'life_account_id'
]
=
$life_account_id
;
$where
[
'ORDER'
]
=
[
"create_time"
=>
"DESC"
];
$subShopList
=
SubShop
::
getRecords
(
$where
);
return
$subShopList
;
}
/**
* 门店名称是否重复
*
*/
public
static
function
isName
(
$name
=
''
)
{
if
(
empty
(
$name
))
{
return
false
;
}
$colums
=
[
'name'
=>
$name
];
$subShop
=
SubShop
::
getRecord
(
$colums
);
if
(
!
empty
(
$subShop
))
{
return
false
;
}
return
true
;
}
/**
* 门店手机号是否重复
*
*/
public
static
function
isPhone
(
$phone
=
''
)
{
if
(
empty
(
$phone
))
{
return
false
;
}
$colums
=
[
'phone'
=>
$phone
];
$subShop
=
SubShop
::
getRecord
(
$colums
);
if
(
!
empty
(
$subShop
))
{
return
false
;
}
return
true
;
}
/**
*判断长度
*
*/
public
static
function
utf8Strlen
(
$string
=
null
)
{
// 将字符串分解为单元
preg_match_all
(
"/./us"
,
$string
,
$match
);
// // 返回单元个数
return
count
(
$match
[
0
]);
}
/**
* 通过发号器拿 id (非雪花)
* number,获取店铺shop_id用生活号id后两位,商品相关的这里是shop_id的后两位
* @param $number
* @param $type
* @param int $count
* @return array|mixed
*/
public
static
function
getIdgenId
(
$number
,
$type
,
$count
=
1
)
{
$res
=
Idgen
::
get
(
appConfig
(
'idgen.partner'
),
appConfig
(
'idgen.key'
),
[],
[[
"type"
=>
$type
,
'number'
=>
(
int
)
$number
,
"count"
=>
$count
]]);
return
$res
[
'id_datetime'
][
$type
]
??
[];
}
public
static
function
getSnowIdgenId
(
$type
,
$count
=
1
)
{
$res
=
Idgen
::
get
(
appConfig
(
'idgen.partner'
),
appConfig
(
'idgen.key'
),
[[
"type"
=>
$type
,
"count"
=>
$count
]],
[]);
return
$res
[
'id_snow'
][
$type
]
??
[];
}
}
\ No newline at end of file
application/services/shop/SubShopService.php
0 → 100644
View file @
f73c5222
<?php
namespace
App\Services\goods
;
use
App\Models\goods\mysql\Category
;
class
CategoryService
{
public
static
function
getCategoryList
()
{
//todo::加上redis
$allCaregoryList
=
Category
::
getRecordList
([],
[
'category_id'
,
'parent_category_id'
,
'name'
,
'level'
]);
$data
=
[];
if
(
!
empty
(
$allCaregoryList
))
{
foreach
(
$allCaregoryList
as
$caregory
)
{
if
(
$caregory
[
"level"
]
==
Category
::
LEVEL_1
)
{
$data
[
"level_1"
][]
=
[
"category_id"
=>
$caregory
[
"category_id"
],
"name"
=>
$caregory
[
"name"
]
];
}
if
(
$caregory
[
"level"
]
==
Category
::
LEVEL_2
)
{
$data
[
"level_2"
][
$caregory
[
"parent_category_id"
]][]
=
[
"category_id"
=>
$caregory
[
"category_id"
],
"name"
=>
$caregory
[
"name"
]
];
}
}
}
return
$data
;
}
}
\ No newline at end of file
conf/application.ini
View file @
f73c5222
...
@@ -3,7 +3,7 @@ application.directory = APP_PATH
...
@@ -3,7 +3,7 @@ application.directory = APP_PATH
application.bootstrap
=
APP_PATH "/Bootstrap.php"
application.bootstrap
=
APP_PATH "/Bootstrap.php"
application.library
=
APP_PATH"/library"
application.library
=
APP_PATH"/library"
application.library.namespace
=
""
application.library.namespace
=
""
application.modules
=
"Index,Test,Goods,Shop"
application.modules
=
"Index,Test,Goods,Shop
,Distribution
"
appid
=
"goods"
appid
=
"goods"
;AES密钥
;AES密钥
...
...
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