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
2a75bfae
Commit
2a75bfae
authored
Sep 13, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: 分类标签逻辑接口
parent
a1d611f4
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
243 additions
and
2 deletions
+243
-2
MarketingException.php
application/exception/custom/MarketingException.php
+3
-1
BusinesscircleValidate.php
application/library/Validate/BusinesscircleValidate.php
+39
-0
TagValidate.php
application/library/Validate/TagValidate.php
+33
-0
Tag.php
application/models/marketing/mysql/Tag.php
+11
-0
Businesscircle.php
application/modules/Marketing/controllers/Businesscircle.php
+5
-1
Tag.php
application/modules/Marketing/controllers/Tag.php
+56
-0
TagService.php
application/services/marketing/TagService.php
+96
-0
No files found.
application/exception/custom/MarketingException.php
View file @
2a75bfae
...
...
@@ -13,7 +13,8 @@ class MarketingException extends BaseException
const
LIFE_ACCOUNT_NO_EXIST
=
16
;
const
RELATION_ALREADY_EXIST
=
17
;
const
TAKE_PLACE_NOT_EXIST
=
20
;
const
BUSINESS_CIRCLE_IS_EXIST
=
34
;
const
BUSINESS_CIRCLE_IS_EXIST
=
39
;
const
TAG_IS_EXIST
=
40
;
protected
$cus
=
[
0
=>
'活动名称不能为空'
,
...
...
@@ -41,5 +42,6 @@ class MarketingException extends BaseException
22
=>
"自提点不能为空"
,
33
=>
'分润金额+手续费不能大于售价金额'
,
self
::
BUSINESS_CIRCLE_IS_EXIST
=>
'此商圈名已经存在'
,
self
::
TAG_IS_EXIST
=>
'此分类标签已经存在'
,
];
}
\ No newline at end of file
application/library/Validate/BusinesscircleValidate.php
0 → 100644
View file @
2a75bfae
<?php
namespace
Validate
;
/**
* Class Businesscircle
*
* @package Validate
*/
class
BusinessCircleValidate
extends
BaseValidate
{
protected
$rule
=
[
'business_circle_id'
=>
'require'
,
'business_circle_name'
=>
'require'
,
'longitude'
=>
'require'
,
'latitude'
=>
'require'
,
'location'
=>
'require'
,
];
protected
$message
=
[
"business_circle_id"
=>
"business_circle_id 不能为空"
,
'business_circle_name'
=>
'商圈名称不能为空'
,
'longitude'
=>
'经度不能为空'
,
'latitude'
=>
'纬度不能为空'
,
'location'
=>
'详细地址不能为空'
,
];
public
function
sceneDetail
()
{
return
$this
->
only
([
'business_circle_id'
])
->
append
(
"business_circle_id"
,
"require"
);
}
public
function
sceneDelete
()
{
return
$this
->
only
([
'business_circle_id'
])
->
append
(
"business_circle_id"
,
"require"
);
}
}
\ No newline at end of file
application/library/Validate/TagValidate.php
0 → 100644
View file @
2a75bfae
<?php
namespace
Validate
;
/**
* Class TagValidate
*
* @package Validate
*/
class
TagValidate
extends
BaseValidate
{
protected
$rule
=
[
'tag_id'
=>
'require'
,
'tag_name'
=>
'require'
,
];
protected
$message
=
[
"tag_id"
=>
"tag_id 不能为空"
,
"tag_name"
=>
"tag_id 不能为空"
,
];
public
function
sceneDetail
()
{
return
$this
->
only
([
'tag_id'
])
->
append
(
"tag_id"
,
"require"
);
}
public
function
sceneDelete
()
{
return
$this
->
only
([
'tag_id'
])
->
append
(
"tag_id"
,
"require"
);
}
}
\ No newline at end of file
application/models/marketing/mysql/Tag.php
View file @
2a75bfae
...
...
@@ -10,6 +10,9 @@ class Tag extends MysqlBase
const
CONFIG_INDEX
=
'marketing'
;
const
PRIMARY_KEY
=
'tag_id'
;
const
STATUS_IS_DEL_NO
=
0
;
const
STATUS_IS_DEL_YES
=
1
;
public
static
function
getRecord
(
$where
,
$columns
=
[])
{
if
(
empty
(
$columns
))
{
...
...
@@ -18,6 +21,14 @@ class Tag extends MysqlBase
return
self
::
get
(
$columns
,
$where
,
[]);
}
public
static
function
getRecords
(
$where
,
$columns
=
[])
{
if
(
empty
(
$columns
))
{
$columns
=
'*'
;
}
return
self
::
select
(
$columns
,
$where
,
[]);
}
public
static
function
getRecordMaster
(
$where
,
$columns
=
[])
{
if
(
empty
(
$columns
))
{
...
...
application/modules/Marketing/controllers/Businesscircle.php
View file @
2a75bfae
...
...
@@ -2,7 +2,7 @@
use
App\Base\Base
;
use
\App\Services\marketing\BusinessCircleService
;
use
\Validate\
MarketingInfo
Validate
;
use
\Validate\
BusinessCircle
Validate
;
class
BusinesscircleController
extends
Base
{
...
...
@@ -23,6 +23,8 @@ class BusinesscircleController extends Base
*/
public
function
detailAction
()
{
(
new
BusinessCircleValidate
())
->
scene
(
"detail"
)
->
validate
();
$params
=
$this
->
params
;
$list
=
BusinessCircleService
::
businessCircleDetail
(
$params
);
$this
->
success
([
"result"
=>
$list
]);
...
...
@@ -45,6 +47,8 @@ class BusinesscircleController extends Base
*/
public
function
deleteAction
()
{
(
new
BusinessCircleValidate
())
->
scene
(
"delete"
)
->
validate
();
$params
=
$this
->
params
;
$list
=
BusinessCircleService
::
businessCircleDelete
(
$params
);
$this
->
success
([
"result"
=>
$list
]);
...
...
application/modules/Marketing/controllers/Tag.php
0 → 100644
View file @
2a75bfae
<?php
use
App\Base\Base
;
use
\App\Services\marketing\TagService
;
use
\Validate\TagValidate
;
class
TagController
extends
Base
{
/**
* 分类标签数据列表
* @throws Exception
*/
public
function
listAction
()
{
$params
=
$this
->
params
;
$list
=
TagService
::
getList
(
$params
);
$this
->
success
([
"result"
=>
$list
]);
}
/**
* 分类标签详情
* @throws Exception
*/
public
function
detailAction
()
{
(
new
TagValidate
())
->
scene
(
"detail"
)
->
validate
();
$params
=
$this
->
params
;
$list
=
TagService
::
tagDetail
(
$params
);
$this
->
success
([
"result"
=>
$list
]);
}
/**
* 分类标签编辑(包括add 和 update)
* @throws Exception
*/
public
function
editAction
()
{
$params
=
$this
->
params
;
$list
=
TagService
::
tagEdit
(
$params
);
$this
->
success
([
"result"
=>
$list
]);
}
/**
* 分类标签删除(逻辑删除)
* @throws Exception
*/
public
function
deleteAction
()
{
(
new
TagValidate
())
->
scene
(
"delete"
)
->
validate
();
$params
=
$this
->
params
;
$list
=
TagService
::
tagDelete
(
$params
);
$this
->
success
([
"result"
=>
$list
]);
}
}
\ No newline at end of file
application/services/marketing/TagService.php
0 → 100644
View file @
2a75bfae
<?php
/**
* Tag
* Class Tag
* @package App\Models\marketing\mysql
*/
namespace
App\Services\marketing
;
use
App\Exception\custom\MarketingException
;
use
App\Models\marketing\mysql\Tag
;
class
TagService
{
/**
* 分类标签详情
* @param array $params
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public
static
function
tagDetail
(
$params
=
[])
{
return
Tag
::
getRecord
([
"tag_id"
=>
$params
[
"tag_id"
]]);
}
/**
* 分类标签编辑
* @param array $params
* @return \Api\PhpUtils\Mysql\MysqlBase
* @throws MarketingException
*/
public
static
function
tagEdit
(
$params
=
[])
{
$tagId
=
empty
(
$params
[
"tag_id"
])
?
0
:
$params
[
"tag_id"
];
$data
=
[];
$data
[
"tag_name"
]
=
empty
(
$params
[
"tag_name"
])
?
""
:
$params
[
"tag_name"
];
$data
[
"type"
]
=
empty
(
$params
[
"type"
])
?
1
:
$params
[
"type"
];
$data
[
"is_delete"
]
=
empty
(
$params
[
"is_delete"
])
?
Tag
::
STATUS_IS_DEL_NO
:
$params
[
"is_delete"
];
if
(
!
empty
(
$tagId
))
{
$tag
=
Tag
::
getRecordMaster
([
"tag_name"
=>
$data
[
"tag_name"
],
"tag_id[!]"
=>
$tagId
]);
if
(
!
empty
(
$tag
))
{
throw
new
MarketingException
([
'cus'
=>
MarketingException
::
TAG_IS_EXIST
]);
}
$result
=
Tag
::
save
(
$data
,
[
"tag_id"
=>
$tagId
]);
}
else
{
$tag
=
Tag
::
getRecordMaster
([
"tag_name"
=>
$data
[
"tag_name"
]]);
if
(
!
empty
(
$tag
))
{
throw
new
MarketingException
([
'cus'
=>
MarketingException
::
TAG_IS_EXIST
]);
}
$result
=
Tag
::
save
(
$data
);
}
return
$result
;
}
/**
* 逻辑删除分类标签
* @param array $params
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public
static
function
tagDelete
(
$params
=
[])
{
$tagId
=
$params
[
"tag_id"
];
$data
=
[];
$data
[
"is_delete"
]
=
empty
(
$params
[
"is_delete"
])
?
0
:
$params
[
"is_delete"
];
return
Tag
::
save
(
$data
,
[
"tag_id"
=>
$tagId
]);
}
/**
* 分类标签列表
* @param array $params
* @return array
*/
public
static
function
getList
(
$params
=
[])
{
$params
[
'page'
]
=
!
empty
(
$params
[
'page'
])
?
$params
[
'page'
]
:
1
;
$limit
=
!
empty
(
$params
[
'page_size'
])
?
$params
[
'page_size'
]
:
20
;
$page
=
(
$params
[
'page'
]
-
1
)
*
$limit
;
$where
=
[];
if
(
!
empty
(
$params
[
"tag_name"
]))
{
$where
[
"tag_name[~]"
]
=
$params
[
"tag_name"
];
}
$where
[
'is_delete'
]
=
Tag
::
STATUS_IS_DEL_NO
;
$where
[
'ORDER'
]
=
[
"tag_id"
=>
"DESC"
];
$where
[
'LIMIT'
]
=
[
$page
,
$limit
];
$list
=
Tag
::
getRecords
(
$where
);
unset
(
$where
[
'LIMIT'
]);
unset
(
$where
[
'ORDER'
]);
$count
=
Tag
::
count
(
"*"
,
$where
);
return
[
'result'
=>
$list
,
'count'
=>
$count
];
}
}
\ 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