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
3437705c
Commit
3437705c
authored
Jun 21, 2021
by
jianghaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: 添加店铺
parent
f73c5222
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
334 additions
and
151 deletions
+334
-151
Code.php
application/exception/custom/Code.php
+4
-0
DistributionException.php
application/exception/custom/DistributionException.php
+26
-0
DistributionGoodsException.php
application/exception/custom/DistributionGoodsException.php
+26
-0
DistributorException.php
application/exception/custom/DistributorException.php
+23
-0
Distribution.php
application/models/distribution/mysql/Distribution.php
+0
-3
Distributor.php
application/models/distribution/mysql/Distributor.php
+8
-8
Distribution.php
...ication/modules/Distribution/controllers/Distribution.php
+16
-8
Distributor.php
application/modules/Distribution/controllers/Distributor.php
+76
-0
Shop.php
application/modules/Shop/controllers/Shop.php
+36
-2
DistributionService.php
application/services/distribution/DistributionService.php
+8
-2
DistributorService.php
application/services/distribution/DistributorService.php
+33
-126
ShopService.php
application/services/shop/ShopService.php
+78
-2
No files found.
application/exception/custom/Code.php
View file @
3437705c
...
...
@@ -15,4 +15,8 @@ class Code
const
SIGN
=
102000
;
const
GOODS
=
108000
;
const
SHOP
=
109000
;
const
DISTRIBUTOR
=
110000
;
const
DISTRIBUTION
=
111000
;
}
\ No newline at end of file
application/exception/custom/DistributionException.php
0 → 100644
View file @
3437705c
<?php
namespace
App\Exception\custom
;
use
App\Exception\BaseException
;
/**
* Class TestException
* @package App\Exception\custom
*/
class
TestException
extends
BaseException
{
/**
* Test 模块的错误码起始值
* 最终用户获取到的错误码,是 $base_code + 指定的 $cus 的 key
* @var int
*/
protected
$base_code
=
Code
::
TEST
;
protected
$cus
=
[
0
=>
'test error'
,
1
=>
'test error2'
];
}
\ No newline at end of file
application/exception/custom/DistributionGoodsException.php
0 → 100644
View file @
3437705c
<?php
namespace
App\Exception\custom
;
use
App\Exception\BaseException
;
/**
* Class TestException
* @package App\Exception\custom
*/
class
TestException
extends
BaseException
{
/**
* Test 模块的错误码起始值
* 最终用户获取到的错误码,是 $base_code + 指定的 $cus 的 key
* @var int
*/
protected
$base_code
=
Code
::
TEST
;
protected
$cus
=
[
0
=>
'test error'
,
1
=>
'test error2'
];
}
\ No newline at end of file
application/exception/custom/DistributorException.php
0 → 100644
View file @
3437705c
<?php
namespace
App\Exception\custom
;
use
App\Exception\BaseException
;
/**
* Class DistributorException
* @package App\Exception\custom
*/
class
DistributorException
extends
BaseException
{
protected
$base_code
=
Code
::
DISTRIBUTOR
;
protected
$cus
=
[
0
=>
'参数不能为空'
,
1
=>
'修改失败'
,
];
}
\ No newline at end of file
application/models/distribution/mysql/Distribution.php
View file @
3437705c
<?php
namespace
App\Models\distribution\mysql
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
Distribution
extends
MysqlBase
...
...
application/models/distribution/mysql/Distributor.php
View file @
3437705c
<?php
namespace
App\Models\shop\mysql
;
namespace
App\Models\distribution\mysql
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
Distributor
extends
MysqlBase
{
const
TABLE_NAME
=
'shop'
;
const
CONFIG_INDEX
=
'goods'
;
const
PRIMARY_KEY
=
'shop_id'
;
const
TABLE_NAME
=
'distributor'
;
const
CONFIG_INDEX
=
'distribution'
;
const
PRIMARY_KEY
=
'id'
;
public
static
function
getRecord
(
$where
,
$colums
=
[])
{
...
...
@@ -61,6 +58,9 @@ class Distributor extends MysqlBase
public
static
function
getCount
(
$where
)
{
return
self
::
count
(
$where
);
if
(
empty
(
$colums
))
{
$colums
=
'*'
;
}
return
self
::
count
(
$colums
,
$where
);
}
}
application/modules/Distribution/controllers/Distribution.php
View file @
3437705c
...
...
@@ -6,18 +6,26 @@ use App\Exception\custom\ShopException;
class
DistributionController
extends
Base
{
/**
*获取团列表
*
*/
public
function
get_distribution_listAction
()
{
$params
=
$this
->
getRequest
()
->
getRequest
();
$distributionList
=
DistributionService
::
getDistributionList
(
$params
);
$this
->
success
([
'result'
=>
$distributionList
]);
}
print_r
(
$params
);
die
();
/**
* 添加团
*/
public
function
add_distributionAction
()
{
# code...
}
$srt
=
DistributionService
::
addDistribution
(
$params
);
print_r
(
$srt
);
}
...
...
application/modules/Distribution/controllers/Distributor.php
0 → 100644
View file @
3437705c
<?php
use
App\Base\Base
;
use
App\Services\distribution\DistributorService
;
use
App\Exception\custom\DistributorException
;
class
DistributorController
extends
Base
{
/**
* 获取团长列表
* 后台管理
*
*/
public
function
distributor_listAction
()
{
$params
=
$this
->
params
;
$distributionList
=
DistributorService
::
distributorList
(
$params
);
$this
->
success
(
$distributionList
);
}
/**
* 获取详情数据
* 后台管理
*
*/
public
function
distributor_infoAction
()
{
$params
=
$this
->
params
;
$distributorInfo
=
DistributorService
::
distributorInfo
(
$params
);
$this
->
success
([
'result'
=>
$distributorInfo
]);
}
/**
* 更新数据
* 后台管理
*
*/
public
function
update_distributorAction
()
{
$params
=
$this
->
params
;
$where
[
'distributor_id'
]
=
$params
[
'distributor_id'
];
if
(
!
empty
(
$params
[
'audit_status'
]))
{
$param
[
'audit_status'
]
=
$params
[
'audit_status'
];
}
if
(
!
empty
(
$params
[
'audit_user_name'
]))
{
$param
[
'audit_user_name'
]
=
$params
[
'audit_user_name'
];
}
$srt
=
DistributorService
::
updateDistributor
(
$param
,
$where
);
if
(
!
empty
(
$srt
))
{
$this
->
success
();
}
else
{
throw
new
DistributorException
([
'cus'
=>
1
]);
}
}
/**
* 添加团长
* 后台管理
*
*/
public
function
add_distributorAction
()
{
}
}
\ No newline at end of file
application/modules/Shop/controllers/Shop.php
View file @
3437705c
...
...
@@ -12,7 +12,7 @@ class ShopController extends Base
*/
public
function
add_shopAction
()
{
$params
=
$this
->
getRequest
()
->
getRequest
()
;
$params
=
$this
->
params
;
$shop
=
ShopService
::
addShop
(
$params
);
if
(
!
empty
(
$shop
))
{
$this
->
success
();
...
...
@@ -27,11 +27,45 @@ class ShopController extends Base
*/
public
function
get_shop_listAction
()
{
$params
=
$this
->
getRequest
()
->
getRequest
()
;
$params
=
$this
->
params
;
$subShopList
=
ShopService
::
getShopList
(
$params
);
$this
->
success
([
'result'
=>
$subShopList
]);
}
/**
* 店铺编辑接口
*
*/
public
function
update_shopAction
()
{
$params
=
$this
->
params
;
$where
[
'stores_id'
]
=
!
empty
(
$params
[
'stores_id'
])
?
$params
[
'stores_id'
]
:
''
;
$subShopList
=
ShopService
::
updateShop
(
$params
,
$where
);
}
/**
* 获取数据
*
*/
public
function
get_shop_infoAction
(
$value
=
''
)
{
$params
=
$this
->
params
;
$param
[
'stores_id'
]
=
!
empty
(
$params
[
'stores_id'
])
?
$params
[
'stores_id'
]
:
''
;
$subShopList
=
ShopService
::
getShopInfo
(
$param
);
}
/**
* 后台门店列表
*
*/
public
function
shop_listAction
()
{
$params
=
$this
->
params
;
$subShopList
=
ShopService
::
opShopList
(
$params
);
$this
->
success
(
$subShopList
);
}
}
\ No newline at end of file
application/services/distribution/DistributionService.php
View file @
3437705c
...
...
@@ -3,7 +3,7 @@
namespace
App\Services\distribution
;
use
App\Models\
shop
\mysql\Distribution
;
use
App\Models\
distribution
\mysql\Distribution
;
use
Api\PhpUtils\Validate\Validate
;
use
Api\PhpServices\Idgen\Idgen
;
...
...
@@ -24,6 +24,12 @@ class DistributionService
public
static
function
getDistributionList
(
$params
)
{
$where
[
'ORDER'
]
=
[
"create_time"
=>
"DESC"
];
$distributionList
=
Distribution
::
getRecords
(
$where
);
$count
=
Distribution
::
getCount
([
''
]);
return
$distributionList
;
}
...
...
application/services/distribution/DistributorService.php
View file @
3437705c
<?php
namespace
App\Services\
shop
;
namespace
App\Services\
distribution
;
use
App\Models\shop\mysql\Shop
;
use
App\Models\shop\mysql\SubShop
;
use
App\Models\distribution\mysql\Distributor
;
use
Api\PhpUtils\Validate\Validate
;
use
Api\PhpServices\Idgen\Idgen
;
// use Validate\ShopValidate;
use
App\Exception\custom\ShopException
;
use
Api\PhpServices\Sensitive\Sensitive
;
use
App\Exception\custom\DistributorException
;
class
DistributorService
{
public
static
function
addShop
(
$params
)
/**
* 查询
*
*/
public
static
function
distributorList
(
$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
]);
}
$params
[
'page'
]
=
!
empty
(
$params
[
'page'
])
?
$params
[
'page'
]
:
1
;
$limit
=
!
empty
(
$params
[
'page_size'
])
?
$params
[
'page_size'
]
:
20
;
$page
=
(
$params
[
'page'
]
-
1
)
*
$limit
;
if
(
empty
(
$phone
))
{
throw
new
ShopException
([
'cus'
=>
1
])
;
if
(
!
empty
(
$params
[
'audit_status'
]
))
{
$where
[
'audit_status'
]
=
$params
[
'audit_status'
]
;
}
// $is_mobile = ( new Validate)->isMobile($phone);
// if (empty($is_mobile)) {
// throw new ShopException(['cus'=>2]);
// }
if
(
empty
(
$name
))
{
throw
new
ShopException
([
'cus'
=>
3
]);
if
(
!
empty
(
$params
[
'audit_user_name'
]))
{
$where
[
'audit_user_name'
]
=
$params
[
'audit_user_name'
];
}
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
;
$where
[
'LIMIT'
]
=
[
$page
,
$limit
];
$list
=
Distributor
::
getRecords
(
$where
);
unset
(
$where
[
'LIMIT'
]);
unset
(
$where
[
'ORDER'
]);
$count
=
Distributor
::
getCount
(
$where
);
$data
=
[
'result'
=>
$list
,
'count'
=>
$count
];
return
$data
;
}
/**
* 门店名称是否重复
*
*/
public
static
function
isName
(
$name
=
''
)
public
static
function
distributorInfo
(
$params
)
{
if
(
empty
(
$name
))
{
return
false
;
}
$colums
=
[
'name'
=>
$name
];
$subShop
=
SubShop
::
getRecord
(
$colums
);
if
(
!
empty
(
$subShop
))
{
return
false
;
}
return
true
;
$where
[
'distributor_id'
]
=
!
empty
(
$params
[
'distributor_id'
])
?
$params
[
'distributor_id'
]
:
''
;
$info
=
Distributor
::
getRecord
(
$where
);
return
$info
;
}
/**
*
门店手机号是否重复
*
更新数据
*
*/
public
static
function
isPhone
(
$phone
=
''
)
public
static
function
updateDistributor
(
$params
,
$where
)
{
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
]);
$where
[
'distributor_id'
]
=
!
empty
(
$where
[
'distributor_id'
])
?
$where
[
'distributor_id'
]
:
''
;
$info
=
Distributor
::
updateRecord
(
$params
,
$where
);
return
$info
;
}
/**
...
...
application/services/shop/ShopService.php
View file @
3437705c
...
...
@@ -15,7 +15,10 @@ use Api\PhpServices\Sensitive\Sensitive;
class
ShopService
{
/**
* 添加门店
*
*/
public
static
function
addShop
(
$params
)
{
$life_account_id
=
!
empty
(
$params
[
'life_account_id'
])
?
$params
[
'life_account_id'
]
:
''
;
...
...
@@ -85,7 +88,7 @@ class ShopService
public
static
function
getShopList
(
$params
)
{
$life_account_id
=
!
empty
(
$params
[
'life_account_id'
])
?
$params
[
'life_account_id'
]
:
''
;
$life_account_id
=
!
empty
(
$params
[
'life_account_id'
])
?
$params
[
'life_account_id'
]
:
11
;
$phone
=
!
empty
(
$params
[
'phone'
])
?
$params
[
'phone'
]
:
''
;
$shop_id
=
!
empty
(
$params
[
'shop_id'
])
?
$params
[
'shop_id'
]
:
''
;
$name
=
!
empty
(
$params
[
'name'
])
?
$params
[
'name'
]
:
''
;
...
...
@@ -99,6 +102,79 @@ class ShopService
}
/**
* op后台查询查询
*
*/
public
static
function
opShopList
(
$params
)
{
$params
[
'page'
]
=
!
empty
(
$params
[
'page'
])
?
$params
[
'page'
]
:
1
;
$limit
=
!
empty
(
$params
[
'page_size'
])
?
$params
[
'page_size'
]
:
20
;
$page
=
(
$params
[
'page'
]
-
1
)
*
$limit
;
$where
[
'ORDER'
]
=
[
"create_time"
=>
"DESC"
];
$where
[
'LIMIT'
]
=
[
$page
,
$limit
];
$list
=
SubShop
::
getRecords
(
$where
);
unset
(
$where
[
'LIMIT'
]);
unset
(
$where
[
'ORDER'
]);
$count
=
SubShop
::
getCount
(
$where
);
$data
=
[
'result'
=>
$list
,
'count'
=>
$count
];
return
$data
;
}
/**
*
*
*/
public
static
function
updateShop
(
$params
,
$where
)
{
$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'
]
:
''
;
$phone
=
!
empty
(
$params
[
'phone'
])
?
$params
[
'phone'
]
:
''
;
if
(
!
empty
(
$name
)){
$detectParams
=
[
'businessId'
=>
1
,
'text'
=>
!
empty
(
$name
)
?
$name
:
''
,
'scene'
=>
1
,
];
$sensitive
=
(
new
Sensitive
)
->
detect
(
$detectParams
);
if
(
!
empty
(
$sensitive
[
'data'
]))
{
throw
new
ShopException
([
'cus'
=>
4
]);
}
$colums
[
'name'
]
=
$name
;
}
if
(
!
empty
(
$address_lng
))
{
$colums
[
'address_lng'
]
=
$address_lng
;
}
if
(
!
empty
(
$address_lat
))
{
$colums
[
'address_lat'
]
=
$address_lat
;
}
if
(
!
empty
(
$address
))
{
$colums
[
'address'
]
=
$address
;
}
if
(
!
empty
(
$phone
))
{
$colums
[
'phone'
]
=
$phone
;
}
$subShop
=
SubShop
::
updateRecord
(
$colums
,
$where
);
return
$subShop
;
}
public
static
function
getShopInfo
(
$params
)
{
$subShopInfo
=
SubShop
::
getRecord
(
$params
);
return
$subShopInfo
;
}
/**
* 门店名称是否重复
*
...
...
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