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
8e09e34d
Commit
8e09e34d
authored
Sep 16, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Plain Diff
update: 处理冲突
parents
a4899e40
0da14b43
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
630 additions
and
65 deletions
+630
-65
MarketingException.php
application/exception/custom/MarketingException.php
+4
-0
BusinesscircleValidate.php
application/library/Validate/BusinesscircleValidate.php
+39
-0
TagValidate.php
application/library/Validate/TagValidate.php
+33
-0
BusinessCircle.php
application/models/marketing/mysql/BusinessCircle.php
+52
-0
Tag.php
application/models/marketing/mysql/Tag.php
+52
-0
TakePlace.php
application/models/marketing/mysql/TakePlace.php
+8
-36
Businesscircle.php
application/modules/Marketing/controllers/Businesscircle.php
+56
-0
Marketinggoods.php
application/modules/Marketing/controllers/Marketinggoods.php
+1
-1
Tag.php
application/modules/Marketing/controllers/Tag.php
+56
-0
BusinessCircleService.php
application/services/marketing/BusinessCircleService.php
+98
-0
TagService.php
application/services/marketing/TagService.php
+106
-0
TakePlaceService.php
application/services/marketing/TakePlaceService.php
+125
-28
No files found.
application/exception/custom/MarketingException.php
View file @
8e09e34d
...
@@ -26,6 +26,8 @@ class MarketingException extends BaseException
...
@@ -26,6 +26,8 @@ class MarketingException extends BaseException
const
COLONEL_TAKE_PLACE_EDIT_FAILED
=
36
;
const
COLONEL_TAKE_PLACE_EDIT_FAILED
=
36
;
const
COLONEL_APPLY_EXIST
=
37
;
const
COLONEL_APPLY_EXIST
=
37
;
const
COLONEL_DATE_ERROR
=
38
;
const
COLONEL_DATE_ERROR
=
38
;
const
BUSINESS_CIRCLE_IS_EXIST
=
39
;
const
TAG_IS_EXIST
=
40
;
protected
$cus
=
[
protected
$cus
=
[
0
=>
'活动名称不能为空'
,
0
=>
'活动名称不能为空'
,
...
@@ -67,5 +69,7 @@ class MarketingException extends BaseException
...
@@ -67,5 +69,7 @@ class MarketingException extends BaseException
self
::
COLONEL_TAKE_PLACE_EDIT_FAILED
=>
'修改团长自提点失败'
,
self
::
COLONEL_TAKE_PLACE_EDIT_FAILED
=>
'修改团长自提点失败'
,
self
::
COLONEL_APPLY_EXIST
=>
'当前用户已提交团长申请'
,
self
::
COLONEL_APPLY_EXIST
=>
'当前用户已提交团长申请'
,
self
::
COLONEL_DATE_ERROR
=>
'当前日期的配置不能修改'
,
self
::
COLONEL_DATE_ERROR
=>
'当前日期的配置不能修改'
,
self
::
BUSINESS_CIRCLE_IS_EXIST
=>
'此商圈名已经存在'
,
self
::
TAG_IS_EXIST
=>
'此分类标签已经存在'
,
];
];
}
}
application/library/Validate/BusinesscircleValidate.php
0 → 100644
View file @
8e09e34d
<?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 @
8e09e34d
<?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/BusinessCircle.php
0 → 100644
View file @
8e09e34d
<?php
namespace
App\Models\marketing\mysql
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
BusinessCircle
extends
MysqlBase
{
const
TABLE_NAME
=
'business_circle'
;
const
CONFIG_INDEX
=
'marketing'
;
const
PRIMARY_KEY
=
'business_circle_id'
;
const
STATUS_IS_DEL_NO
=
0
;
const
STATUS_IS_DEL_YES
=
1
;
public
static
function
getRecord
(
$where
,
$columns
=
[])
{
if
(
empty
(
$columns
))
{
$columns
=
'*'
;
}
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
))
{
$columns
=
'*'
;
}
return
self
::
selectMaster
(
$columns
,
$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
);
}
}
application/models/marketing/mysql/Tag.php
0 → 100644
View file @
8e09e34d
<?php
namespace
App\Models\marketing\mysql
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
Tag
extends
MysqlBase
{
const
TABLE_NAME
=
'tag'
;
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
))
{
$columns
=
'*'
;
}
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
))
{
$columns
=
'*'
;
}
return
self
::
selectMaster
(
$columns
,
$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
);
}
}
application/models/marketing/mysql/TakePlace.php
View file @
8e09e34d
...
@@ -19,42 +19,6 @@ class TakePlace extends MysqlBase
...
@@ -19,42 +19,6 @@ class TakePlace extends MysqlBase
const
STATUS_NORMAL
=
0
;
// 正常
const
STATUS_NORMAL
=
0
;
// 正常
const
STATUS_DELETE
=
1
;
// 删除
const
STATUS_DELETE
=
1
;
// 删除
/**
* 获取
* @param $params
* @return mixed
*/
public
static
function
searchList
(
$params
)
{
$lifeAccountId
=
$params
[
'life_account_id'
]
??
MarketingService
::
getPublicLifeAccountId
();
$keywords
=
$params
[
'keywords'
]
??
''
;
$offset
=
$params
[
'offset'
]
??
0
;
$limit
=
$params
[
'limit'
]
??
20
;
$takePlaceIds
=
$params
[
'take_place_id'
]
??
[];
if
(
!
empty
(
$takePlaceIds
))
{
$where
[
'take_place_id'
]
=
$takePlaceIds
;
}
if
(
$lifeAccountId
)
{
$where
[
'life_account_id'
]
=
$lifeAccountId
;
}
if
(
$keywords
)
{
$where
[
'OR'
]
=
[
'take_place_name[~]'
=>
$keywords
,
'contact_name[~]'
=>
$keywords
,
];
}
$where
[
'is_delete'
]
=
TakePlace
::
STATUS_NORMAL
;
$where
[
'ORDER'
]
=
[
'take_place_id'
=>
'DESC'
];
$where
[
'LIMIT'
]
=
[
$offset
,
$limit
];
$res
[
'list'
]
=
self
::
select
(
'*'
,
$where
);
unset
(
$where
[
'ORDER'
],
$where
[
'LIMIT'
]);
$res
[
'total'
]
=
self
::
count
(
'*'
,
$where
);
return
$res
;
}
public
static
function
getRecord
(
array
$where
,
$column
=
'*'
)
public
static
function
getRecord
(
array
$where
,
$column
=
'*'
)
{
{
return
self
::
get
(
$column
,
$where
);
return
self
::
get
(
$column
,
$where
);
...
@@ -70,4 +34,12 @@ class TakePlace extends MysqlBase
...
@@ -70,4 +34,12 @@ class TakePlace extends MysqlBase
$exist
=
self
::
getRecord
([
'take_place_name'
=>
$takePlaceName
],
[
'take_place_id'
]);
$exist
=
self
::
getRecord
([
'take_place_name'
=>
$takePlaceName
],
[
'take_place_id'
]);
return
!
empty
(
$exist
);
return
!
empty
(
$exist
);
}
}
public
static
function
save
(
$data
,
$where
=
[])
{
if
(
empty
(
$where
))
{
return
self
::
insert
(
$data
,
[]);
}
return
self
::
update
(
$data
,
$where
);
}
}
}
application/modules/Marketing/controllers/Businesscircle.php
0 → 100644
View file @
8e09e34d
<?php
use
App\Base\Base
;
use
\App\Services\marketing\BusinessCircleService
;
use
\Validate\BusinessCircleValidate
;
class
BusinesscircleController
extends
Base
{
/**
* 商圈数据列表
* @throws Exception
*/
public
function
listAction
()
{
$params
=
$this
->
params
;
$list
=
BusinessCircleService
::
getList
(
$params
);
$this
->
success
([
"result"
=>
$list
]);
}
/**
* 商圈详情
* @throws Exception
*/
public
function
detailAction
()
{
(
new
BusinessCircleValidate
())
->
scene
(
"detail"
)
->
validate
();
$params
=
$this
->
params
;
$list
=
BusinessCircleService
::
businessCircleDetail
(
$params
);
$this
->
success
([
"result"
=>
$list
]);
}
/**
* 商圈编辑(包括add 和 update)
* @throws Exception
*/
public
function
editAction
()
{
$params
=
$this
->
params
;
$list
=
BusinessCircleService
::
businessCircleEdit
(
$params
);
$this
->
success
([
"result"
=>
$list
]);
}
/**
* 商圈删除(逻辑删除)
* @throws Exception
*/
public
function
deleteAction
()
{
(
new
BusinessCircleValidate
())
->
scene
(
"delete"
)
->
validate
();
$params
=
$this
->
params
;
$list
=
BusinessCircleService
::
businessCircleDelete
(
$params
);
$this
->
success
([
"result"
=>
$list
]);
}
}
\ No newline at end of file
application/modules/Marketing/controllers/Marketinggoods.php
View file @
8e09e34d
...
@@ -12,7 +12,7 @@ use App\Services\goods\GoodsService;
...
@@ -12,7 +12,7 @@ use App\Services\goods\GoodsService;
class
MarketinggoodsController
extends
Base
class
MarketinggoodsController
extends
Base
{
{
const
KS3_BASE_URL
=
'ks3-cn-beijing.ksyun.com'
;
const
KS3_BASE_URL
=
'ks3-cn-beijing.ksyun
cs
.com'
;
/**
/**
* 获取全部生效营销活动商品列表
* 获取全部生效营销活动商品列表
*
*
...
...
application/modules/Marketing/controllers/Tag.php
0 → 100644
View file @
8e09e34d
<?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/BusinessCircleService.php
0 → 100644
View file @
8e09e34d
<?php
/**
* BusinessCircle
* Class BusinessCircle
* @package App\Models\marketing\mysql
*/
namespace
App\Services\marketing
;
use
App\Exception\custom\MarketingException
;
use
App\Models\marketing\mysql\BusinessCircle
;
class
BusinessCircleService
{
/**
* 商圈详情
* @param array $params
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public
static
function
businessCircleDetail
(
$params
=
[])
{
return
BusinessCircle
::
getRecord
([
"business_circle_id"
=>
$params
[
"business_circle_id"
]]);
}
/**
* 商圈编辑
* @param array $params
* @return \Api\PhpUtils\Mysql\MysqlBase
* @throws MarketingException
*/
public
static
function
businessCircleEdit
(
$params
=
[])
{
$businessCircleId
=
empty
(
$params
[
"business_circle_id"
])
?
0
:
$params
[
"business_circle_id"
];
$data
=
[];
$data
[
"business_circle_name"
]
=
empty
(
$params
[
"business_circle_name"
])
?
""
:
$params
[
"business_circle_name"
];
$data
[
"longitude"
]
=
empty
(
$params
[
"longitude"
])
?
""
:
$params
[
"longitude"
];
$data
[
"latitude"
]
=
empty
(
$params
[
"latitude"
])
?
""
:
$params
[
"latitude"
];
$data
[
"location"
]
=
empty
(
$params
[
"location"
])
?
""
:
$params
[
"location"
];
$data
[
"is_delete"
]
=
empty
(
$params
[
"is_delete"
])
?
BusinessCircle
::
STATUS_IS_DEL_NO
:
$params
[
"is_delete"
];
if
(
!
empty
(
$businessCircleId
))
{
$businessCircle
=
BusinessCircle
::
getRecordMaster
([
"business_circle_name"
=>
$data
[
"business_circle_name"
],
"business_circle_id[!]"
=>
$businessCircleId
]);
if
(
!
empty
(
$businessCircle
))
{
throw
new
MarketingException
([
'cus'
=>
MarketingException
::
BUSINESS_CIRCLE_IS_EXIST
]);
}
$result
=
BusinessCircle
::
save
(
$data
,
[
"business_circle_id"
=>
$businessCircleId
]);
}
else
{
$businessCircle
=
BusinessCircle
::
getRecordMaster
([
"business_circle_name"
=>
$data
[
"business_circle_name"
]]);
if
(
!
empty
(
$businessCircle
))
{
throw
new
MarketingException
([
'cus'
=>
MarketingException
::
BUSINESS_CIRCLE_IS_EXIST
]);
}
$result
=
BusinessCircle
::
save
(
$data
);
}
return
$result
;
}
/**
* 逻辑删除商圈
* @param array $params
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public
static
function
businessCircleDelete
(
$params
=
[])
{
$businessCircleId
=
$params
[
"business_circle_id"
];
$data
=
[];
$data
[
"is_delete"
]
=
empty
(
$params
[
"is_delete"
])
?
0
:
$params
[
"is_delete"
];
return
BusinessCircle
::
save
(
$data
,
[
"business_circle_id"
=>
$businessCircleId
]);
}
/**
* 商圈列表
* @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
[
"business_circle_name"
]))
{
$where
[
"business_circle_name[~]"
]
=
$params
[
"business_circle_name"
];
}
$where
[
'is_delete'
]
=
BusinessCircle
::
STATUS_IS_DEL_NO
;
$where
[
'ORDER'
]
=
[
"business_circle_id"
=>
"DESC"
];
$where
[
'LIMIT'
]
=
[
$page
,
$limit
];
$list
=
BusinessCircle
::
getRecords
(
$where
);
unset
(
$where
[
'LIMIT'
]);
unset
(
$where
[
'ORDER'
]);
$count
=
BusinessCircle
::
count
(
"*"
,
$where
);
return
[
'list'
=>
$list
,
'count'
=>
$count
];
}
}
\ No newline at end of file
application/services/marketing/TagService.php
0 → 100644
View file @
8e09e34d
<?php
/**
* Tag
* Class Tag
* @package App\Models\marketing\mysql
*/
namespace
App\Services\marketing
;
use
App\Exception\custom\MarketingException
;
use
App\Models\marketing\mysql\Tag
;
use
App\Models\marketing\mysql\TakePlace
;
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"
];
$deleteRes
=
Tag
::
save
(
$data
,
[
"tag_id"
=>
$tagId
]);
if
(
!
empty
(
$data
[
"is_delete"
]))
{
$takePlaceIds
=
TakePlace
::
getRecords
([
"tag_id"
=>
$tagId
],
[
"take_place_id"
]);
if
(
!
empty
(
$takePlaceIds
))
{
$ids
=
array_column
(
$takePlaceIds
,
"take_place_id"
);
TakePlace
::
save
([
"tag_id"
=>
0
],
[
"take_place_id"
=>
$ids
]);
}
}
return
$deleteRes
;
}
/**
* 分类标签列表
* @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
application/services/marketing/TakePlaceService.php
View file @
8e09e34d
...
@@ -4,7 +4,9 @@
...
@@ -4,7 +4,9 @@
namespace
App\Services\marketing
;
namespace
App\Services\marketing
;
use
Api\PhpUtils\Http\Request
;
use
Api\PhpUtils\Http\Request
;
use
App\Models\marketing\mysql\BusinessCircle
;
use
App\Models\marketing\mysql\MarketingTakePlace
;
use
App\Models\marketing\mysql\MarketingTakePlace
;
use
App\Models\marketing\mysql\Tag
;
use
App\Models\marketing\mysql\TakePlace
;
use
App\Models\marketing\mysql\TakePlace
;
use
App\Exception\custom\MarketingException
;
use
App\Exception\custom\MarketingException
;
use
Api\PhpUtils\Common\Geo
;
use
Api\PhpUtils\Common\Geo
;
...
@@ -20,7 +22,51 @@ class TakePlaceService
...
@@ -20,7 +22,51 @@ class TakePlaceService
*/
*/
public
static
function
searchList
(
$params
)
public
static
function
searchList
(
$params
)
{
{
return
TakePlace
::
searchList
(
$params
);
$lifeAccountId
=
MarketingService
::
getPublicLifeAccountId
();
$keywords
=
$params
[
'keywords'
]
??
''
;
$takePlaceIds
=
$params
[
'take_place_id'
]
??
[];
$tagIds
=
$params
[
'tag_ids'
]
??
[];
$businessCircleIds
=
$params
[
'business_circle_ids'
]
??
[];
$offset
=
$params
[
'offset'
]
??
0
;
$limit
=
$params
[
'limit'
]
??
20
;
if
(
!
empty
(
$takePlaceIds
))
{
$where
[
'take_place_id'
]
=
$takePlaceIds
;
}
if
(
$lifeAccountId
)
{
$where
[
'life_account_id'
]
=
$lifeAccountId
;
}
if
(
$tagIds
)
{
$where
[
'tag_id'
]
=
$tagIds
;
}
if
(
$businessCircleIds
)
{
$where
[
'business_circle_id'
]
=
$businessCircleIds
;
}
if
(
$keywords
)
{
$where
[
'OR'
]
=
[
'take_place_name[~]'
=>
$keywords
,
'contact_name[~]'
=>
$keywords
,
];
}
$where
[
'is_delete'
]
=
TakePlace
::
STATUS_NORMAL
;
$where
[
'ORDER'
]
=
[
'take_place_id'
=>
'DESC'
];
$where
[
'LIMIT'
]
=
[
$offset
,
$limit
];
$list
=
TakePlace
::
select
(
'*'
,
$where
,
[]);
$tagIds
=
array_unique
(
array_column
(
$list
,
"tag_id"
));
$businessCircleIds
=
array_unique
(
array_column
(
$list
,
"business_circle_id"
));
list
(
$tagArr
,
$businessCircleArr
)
=
self
::
getTagAndBusinessCircle
(
$tagIds
,
$businessCircleIds
);
$data
=
[];
foreach
(
$list
as
$key
=>
$item
)
{
$data
[
$key
]
=
$item
;
$data
[
$key
][
"tag_name"
]
=
empty
(
$tagArr
[
$item
[
"tag_id"
]])
?
""
:
$tagArr
[
$item
[
"tag_id"
]][
"tag_name"
];
$data
[
$key
][
"business_circle_name"
]
=
empty
(
$businessCircleArr
[
$item
[
"business_circle_id"
]])
?
""
:
$businessCircleArr
[
$item
[
"business_circle_id"
]][
"business_circle_name"
];
}
$res
[
'list'
]
=
$data
;
unset
(
$where
[
'ORDER'
],
$where
[
'LIMIT'
]);
$res
[
'total'
]
=
TakePlace
::
count
(
'*'
,
$where
);
return
$res
;
}
}
/**
/**
...
@@ -31,18 +77,64 @@ class TakePlaceService
...
@@ -31,18 +77,64 @@ class TakePlaceService
*/
*/
public
static
function
detail
(
$takePlaceId
)
public
static
function
detail
(
$takePlaceId
)
{
{
return
TakePlace
::
get
(
'*'
,[
'take_place_id'
=>
$takePlaceId
]);
$takePlace
=
TakePlace
::
get
(
'*'
,
[
'take_place_id'
=>
$takePlaceId
],
[]);
$takePlace
[
"tag_name"
]
=
""
;
if
(
!
empty
(
$takePlace
[
"tag_id"
]))
{
$tag
=
TagService
::
tagDetail
([
"tag_id"
=>
$takePlace
[
"tag_id"
]]);
$takePlace
[
"tag_name"
]
=
$tag
[
"tag_name"
];
}
$takePlace
[
"business_circle_name"
]
=
""
;
if
(
!
empty
(
$takePlace
[
"business_circle_id"
]))
{
$businessCircle
=
BusinessCircleService
::
businessCircleDetail
([
"business_circle_id"
=>
$takePlace
[
"business_circle_id"
]]);
$takePlace
[
"business_circle_name"
]
=
$businessCircle
[
"business_circle_name"
];
}
return
$takePlace
;
}
}
/**
/**
* 批量获取自提点信息
* 批量获取自提点信息
* @param $takePlaceIds
* @param $takePlaceIds
* @return
\Api\PhpUtils\Mysql\MysqlBase
* @return
array
*/
*/
public
static
function
getDetailByIds
(
$takePlaceIds
)
public
static
function
getDetailByIds
(
$takePlaceIds
)
{
{
$result
=
TakePlace
::
select
(
'*'
,[
'take_place_id'
=>
$takePlaceIds
]);
$result
=
TakePlace
::
select
(
'*'
,
[
'take_place_id'
=>
$takePlaceIds
],
[]);
return
$result
?
array_column
(
$result
,
null
,
'take_place_id'
)
:
[];
$data
=
[];
if
(
!
empty
(
$result
))
{
$tagIds
=
array_unique
(
array_column
(
$result
,
"tag_id"
));
$businessCircleIds
=
array_unique
(
array_column
(
$result
,
"business_circle_id"
));
list
(
$tagArr
,
$businessCircleArr
)
=
self
::
getTagAndBusinessCircle
(
$tagIds
,
$businessCircleIds
);
foreach
(
$result
as
$key
=>
$item
)
{
$data
[
$item
[
"take_place_id"
]]
=
$item
;
$data
[
$item
[
"take_place_id"
]][
"tag_name"
]
=
empty
(
$tagArr
[
$item
[
"tag_id"
]])
?
""
:
$tagArr
[
$item
[
"tag_id"
]][
"tag_name"
];
$data
[
$item
[
"take_place_id"
]][
"business_circle_name"
]
=
empty
(
$businessCircleArr
[
$item
[
"business_circle_id"
]])
?
""
:
$businessCircleArr
[
$item
[
"business_circle_id"
]][
"business_circle_name"
];
}
}
return
$data
;
}
/**
* @param $tagIds
* @param $businessCircleIds
* @return array
*/
private
static
function
getTagAndBusinessCircle
(
$tagIds
,
$businessCircleIds
)
{
$tagList
=
Tag
::
getRecords
([
"tag_id"
=>
$tagIds
],
[
"tag_id"
,
"tag_name"
]);
$tagArr
=
[];
if
(
!
empty
(
$tagList
))
{
$tagArr
=
array_column
(
$tagList
,
null
,
"tag_id"
);
}
$businessCircleList
=
BusinessCircle
::
getRecords
([
"business_circle_id"
=>
$businessCircleIds
],
[
"business_circle_id"
,
"business_circle_name"
]);
$businessCircleArr
=
[];
if
(
!
empty
(
$businessCircleList
))
{
$businessCircleArr
=
array_column
(
$businessCircleList
,
null
,
"business_circle_id"
);
}
return
[
$tagArr
,
$businessCircleArr
];
}
}
/**
/**
...
@@ -55,7 +147,7 @@ class TakePlaceService
...
@@ -55,7 +147,7 @@ class TakePlaceService
{
{
//验证life_account_id
//验证life_account_id
$lifeAccountId
=
MarketingService
::
getPublicLifeAccountId
();
$lifeAccountId
=
MarketingService
::
getPublicLifeAccountId
();
if
(
isset
(
$params
[
'life_account_id'
])
&&
$params
[
'life_account_id'
]
!=
$lifeAccountId
)
{
if
(
isset
(
$params
[
'life_account_id'
])
&&
$params
[
'life_account_id'
]
!=
$lifeAccountId
)
{
$url
=
config
(
'interface'
,
'merchant.lifeaccount.get_life_account_by_id'
);
$url
=
config
(
'interface'
,
'merchant.lifeaccount.get_life_account_by_id'
);
$lifeAccountRes
=
(
new
Request
())
->
get
(
$url
,
[
"life_account_id"
=>
$params
[
"life_account_id"
]]);
$lifeAccountRes
=
(
new
Request
())
->
get
(
$url
,
[
"life_account_id"
=>
$params
[
"life_account_id"
]]);
...
@@ -66,7 +158,7 @@ class TakePlaceService
...
@@ -66,7 +158,7 @@ class TakePlaceService
$data
[
'life_account_id'
]
=
$params
[
'life_account_id'
]
??
$lifeAccountId
;
$data
[
'life_account_id'
]
=
$params
[
'life_account_id'
]
??
$lifeAccountId
;
$data
[
'take_place_name'
]
=
$params
[
'name'
];
$data
[
'take_place_name'
]
=
$params
[
'name'
];
$data
[
'take_place_pic'
]
=
$params
[
'take_place_pic'
]
??
''
;
$data
[
'take_place_pic'
]
=
$params
[
'take_place_pic'
]
??
''
;
$data
[
'longitude'
]
=
$params
[
'longitude'
];
$data
[
'longitude'
]
=
$params
[
'longitude'
];
$data
[
'latitude'
]
=
$params
[
'latitude'
];
$data
[
'latitude'
]
=
$params
[
'latitude'
];
$data
[
'location'
]
=
$params
[
'location'
];
$data
[
'location'
]
=
$params
[
'location'
];
...
@@ -76,6 +168,9 @@ class TakePlaceService
...
@@ -76,6 +168,9 @@ class TakePlaceService
$data
[
'province'
]
=
$params
[
'province'
];
$data
[
'province'
]
=
$params
[
'province'
];
$data
[
'city'
]
=
$params
[
'city'
];
$data
[
'city'
]
=
$params
[
'city'
];
$data
[
'area'
]
=
$params
[
'area'
];
$data
[
'area'
]
=
$params
[
'area'
];
$data
[
'tag_id'
]
=
empty
(
$params
[
'tag_id'
])
?
0
:
$params
[
'tag_id'
];
$data
[
'business_circle_id'
]
=
empty
(
$params
[
'business_circle_id'
])
?
0
:
$params
[
'business_circle_id'
];
$data
[
'lunch_deliver_time'
]
=
empty
(
$params
[
'lunch_deliver_time'
])
?
null
:
$params
[
'lunch_deliver_time'
];
return
TakePlace
::
insert
(
$data
);
return
TakePlace
::
insert
(
$data
);
}
}
...
@@ -84,15 +179,16 @@ class TakePlaceService
...
@@ -84,15 +179,16 @@ class TakePlaceService
* 删除自提点
* 删除自提点
* @param $takePlaceId
* @param $takePlaceId
* @return \Api\PhpUtils\Mysql\MysqlBase
* @return \Api\PhpUtils\Mysql\MysqlBase
* @throws MarketingException
*/
*/
public
static
function
delete
(
$takePlaceId
)
public
static
function
delete
(
$takePlaceId
)
{
{
if
(
empty
(
self
::
detail
(
$takePlaceId
)))
{
if
(
empty
(
self
::
detail
(
$takePlaceId
)))
{
throw
new
MarketingException
([
'cus'
=>
MarketingException
::
TAKE_PLACE_NOT_EXIST
]);
throw
new
MarketingException
([
'cus'
=>
MarketingException
::
TAKE_PLACE_NOT_EXIST
]);
}
}
return
TakePlace
::
update
(
return
TakePlace
::
update
(
[
'is_delete'
=>
TakePlace
::
STATUS_DELETE
],
[
'is_delete'
=>
TakePlace
::
STATUS_DELETE
],
[
'take_place_id'
=>
$takePlaceId
]
[
'take_place_id'
=>
$takePlaceId
]
);
);
}
}
...
@@ -101,16 +197,17 @@ class TakePlaceService
...
@@ -101,16 +197,17 @@ class TakePlaceService
* @param $marketingPindanId
* @param $marketingPindanId
* @param $takePlaceId
* @param $takePlaceId
* @return \Api\PhpUtils\Mysql\MysqlBase
* @return \Api\PhpUtils\Mysql\MysqlBase
* @throws MarketingException
*/
*/
public
static
function
bindPindanTakePlace
(
$marketingPindanId
,
$takePlaceId
)
public
static
function
bindPindanTakePlace
(
$marketingPindanId
,
$takePlaceId
)
{
{
$data
=
[
$data
=
[
'marketing_pindan_id'
=>
$marketingPindanId
,
'marketing_pindan_id'
=>
$marketingPindanId
,
'take_place_id'
=>
$takePlaceId
,
'take_place_id'
=>
$takePlaceId
,
];
];
//检查关联是否已存在
//检查关联是否已存在
if
(
!
empty
(
MarketingTakePlace
::
get
(
'*'
,
$data
)))
{
if
(
!
empty
(
MarketingTakePlace
::
get
(
'*'
,
$data
)))
{
throw
new
MarketingException
([
'cus'
=>
MarketingException
::
RELATION_ALREADY_EXIST
]);
throw
new
MarketingException
([
'cus'
=>
MarketingException
::
RELATION_ALREADY_EXIST
]);
}
}
...
@@ -148,8 +245,8 @@ class TakePlaceService
...
@@ -148,8 +245,8 @@ class TakePlaceService
$res
=
[
'list'
=>
[],
'total'
=>
0
];
$res
=
[
'list'
=>
[],
'total'
=>
0
];
$where
=
[
'marketing_id'
=>
$marketingId
];
$where
=
[
'marketing_id'
=>
$marketingId
];
if
(
$keywords
)
{
if
(
$keywords
)
{
// $where['OR'] = [
// $where['OR'] = [
// 'take_place_name[~]' => $keywords,
// 'take_place_name[~]' => $keywords,
// 'address[~]' => $keywords,
// 'address[~]' => $keywords,
...
@@ -164,23 +261,23 @@ class TakePlaceService
...
@@ -164,23 +261,23 @@ class TakePlaceService
// $where['LIMIT'] = [$offset, $limit];
// $where['LIMIT'] = [$offset, $limit];
$relations
=
MarketingTakePlace
::
select
(
'*'
,
$where
);
$relations
=
MarketingTakePlace
::
select
(
'*'
,
$where
);
if
(
empty
(
$relations
))
{
if
(
empty
(
$relations
))
{
return
$res
;
return
$res
;
}
}
//获取自提点信息
//获取自提点信息
$makePlaceIds
=
array_column
(
$relations
,
'take_place_id'
);
$makePlaceIds
=
array_column
(
$relations
,
'take_place_id'
);
$takePlaceWhere
=
[
'take_place_id'
=>
$makePlaceIds
];
$takePlaceWhere
=
[
'take_place_id'
=>
$makePlaceIds
];
if
(
!
isset
(
$params
[
'has_delete'
])
)
{
if
(
!
isset
(
$params
[
'has_delete'
])
)
{
$takePlaceWhere
[
'is_delete'
]
=
0
;
$takePlaceWhere
[
'is_delete'
]
=
0
;
}
}
//本页按距离返回列表
//本页按距离返回列表
$res
[
'list'
]
=
self
::
sortByDistance
(
$latitude
,
$longitude
,
TakePlace
::
select
(
'*'
,
$takePlaceWhere
));
$res
[
'list'
]
=
self
::
sortByDistance
(
$latitude
,
$longitude
,
TakePlace
::
select
(
'*'
,
$takePlaceWhere
));
unset
(
$where
[
'ORDER'
],
$where
[
'LIMIT'
]);
unset
(
$where
[
'ORDER'
],
$where
[
'LIMIT'
]);
$res
[
'total'
]
=
MarketingTakePlace
::
count
(
'*'
,
$where
);
$res
[
'total'
]
=
MarketingTakePlace
::
count
(
'*'
,
$where
);
$res
[
'total_page'
]
=
ceil
(
$res
[
'total'
]
/
$limit
);
$res
[
'total_page'
]
=
ceil
(
$res
[
'total'
]
/
$limit
);
return
$res
;
return
$res
;
}
}
...
@@ -195,17 +292,17 @@ class TakePlaceService
...
@@ -195,17 +292,17 @@ class TakePlaceService
private
static
function
sortByDistance
(
$lat
,
$lng
,
$list
)
private
static
function
sortByDistance
(
$lat
,
$lng
,
$list
)
{
{
//未传经纬度
//未传经纬度
if
(
empty
(
$lat
)
||
empty
(
$lng
))
{
if
(
empty
(
$lat
)
||
empty
(
$lng
))
{
return
$list
;
return
$list
;
}
}
//按距离返回自提点列表
//按距离返回自提点列表
$sort
=
[];
$sort
=
[];
if
(
!
empty
(
$list
)
&&
is_array
(
$list
))
{
if
(
!
empty
(
$list
)
&&
is_array
(
$list
))
{
foreach
(
$list
as
&
$item
)
{
foreach
(
$list
as
&
$item
)
{
if
(
$item
[
'longitude'
]
&&
$item
[
'latitude'
])
{
if
(
$item
[
'longitude'
]
&&
$item
[
'latitude'
])
{
$item
[
'distance'
]
=
Geo
::
geoDistance
(
$lat
,
$lng
,
$item
[
'longitude'
],
$item
[
'latitude'
],
true
);
$item
[
'distance'
]
=
Geo
::
geoDistance
(
$lat
,
$lng
,
$item
[
'longitude'
],
$item
[
'latitude'
],
true
);
$sort
[]
=
$item
[
'distance'
];
$sort
[]
=
$item
[
'distance'
];
}
else
{
}
else
{
$item
[
'distance'
]
=
''
;
$item
[
'distance'
]
=
''
;
}
}
}
}
...
...
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