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
40ab9604
Commit
40ab9604
authored
Sep 14, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: 代码整理
parent
3115e349
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
42 deletions
+59
-42
Marketinggoods.php
application/modules/Marketing/controllers/Marketinggoods.php
+1
-1
TakePlaceService.php
application/services/marketing/TakePlaceService.php
+58
-41
No files found.
application/modules/Marketing/controllers/Marketinggoods.php
View file @
40ab9604
...
@@ -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/services/marketing/TakePlaceService.php
View file @
40ab9604
...
@@ -23,18 +23,19 @@ class TakePlaceService
...
@@ -23,18 +23,19 @@ class TakePlaceService
public
static
function
searchList
(
$params
)
public
static
function
searchList
(
$params
)
{
{
$lifeAccountId
=
$params
[
'life_account_id'
]
??
0
;
$lifeAccountId
=
$params
[
'life_account_id'
]
??
0
;
$lifeAccountId
=
MarketingService
::
getPublicLifeAccountId
();
$keywords
=
$params
[
'keywords'
]
??
''
;
$keywords
=
$params
[
'keywords'
]
??
''
;
$takePlaceIds
=
$params
[
'take_place_id'
]
??
[];
$takePlaceIds
=
$params
[
'take_place_id'
]
??
[];
$offset
=
$params
[
'offset'
]
??
0
;
$offset
=
$params
[
'offset'
]
??
0
;
$limit
=
$params
[
'limit'
]
??
20
;
$limit
=
$params
[
'limit'
]
??
20
;
if
(
!
empty
(
$takePlaceIds
))
{
if
(
!
empty
(
$takePlaceIds
))
{
$where
[
'take_place_id'
]
=
$takePlaceIds
;
$where
[
'take_place_id'
]
=
$takePlaceIds
;
}
}
if
(
$lifeAccountId
)
{
if
(
$lifeAccountId
)
{
$where
[
'life_account_id'
]
=
$lifeAccountId
;
$where
[
'life_account_id'
]
=
$lifeAccountId
;
}
}
if
(
$keywords
)
{
if
(
$keywords
)
{
$where
[
'OR'
]
=
[
$where
[
'OR'
]
=
[
'take_place_name[~]'
=>
$keywords
,
'take_place_name[~]'
=>
$keywords
,
'contact_name[~]'
=>
$keywords
,
'contact_name[~]'
=>
$keywords
,
...
@@ -45,7 +46,7 @@ class TakePlaceService
...
@@ -45,7 +46,7 @@ class TakePlaceService
$where
[
'LIMIT'
]
=
[
$offset
,
$limit
];
$where
[
'LIMIT'
]
=
[
$offset
,
$limit
];
$res
[
'list'
]
=
TakePlace
::
select
(
'*'
,
$where
,
[]);
$res
[
'list'
]
=
TakePlace
::
select
(
'*'
,
$where
,
[]);
unset
(
$where
[
'ORDER'
],
$where
[
'LIMIT'
]);
unset
(
$where
[
'ORDER'
],
$where
[
'LIMIT'
]);
$res
[
'total'
]
=
TakePlace
::
count
(
'*'
,
$where
);
$res
[
'total'
]
=
TakePlace
::
count
(
'*'
,
$where
);
return
$res
;
return
$res
;
...
@@ -75,7 +76,7 @@ class TakePlaceService
...
@@ -75,7 +76,7 @@ class TakePlaceService
}
}
/**
/**
*
批量获取自提点信息
* 批量获取自提点信息
* @param $takePlaceIds
* @param $takePlaceIds
* @return array
* @return array
*/
*/
...
@@ -85,18 +86,8 @@ class TakePlaceService
...
@@ -85,18 +86,8 @@ class TakePlaceService
$data
=
[];
$data
=
[];
if
(
!
empty
(
$result
))
{
if
(
!
empty
(
$result
))
{
$tagIds
=
array_unique
(
array_column
(
$result
,
"tag_id"
));
$tagIds
=
array_unique
(
array_column
(
$result
,
"tag_id"
));
$tagList
=
Tag
::
getRecords
([
"tag_id"
=>
$tagIds
],
[
"tag_id"
,
"tag_name"
]);
$tagArr
=
[];
if
(
!
empty
(
$tagList
))
{
$tagArr
=
array_column
(
$tagList
,
null
,
"tag_id"
);
}
$businessCircleIds
=
array_unique
(
array_column
(
$result
,
"business_circle_id"
));
$businessCircleIds
=
array_unique
(
array_column
(
$result
,
"business_circle_id"
));
$businessCircleList
=
BusinessCircle
::
getRecords
([
"business_circle_id"
=>
$businessCircleIds
],
[
"business_circle_id"
,
"business_circle_name"
]);
list
(
$tagArr
,
$businessCircleArr
)
=
self
::
getTagAndBusinessCircle
(
$tagIds
,
$businessCircleIds
);
$businessCircleArr
=
[];
if
(
!
empty
(
$businessCircleList
))
{
$businessCircleArr
=
array_column
(
$businessCircleList
,
null
,
"business_circle_id"
);
}
foreach
(
$result
as
$key
=>
$item
)
{
foreach
(
$result
as
$key
=>
$item
)
{
$data
[
$item
[
"take_place_id"
]]
=
$item
;
$data
[
$item
[
"take_place_id"
]]
=
$item
;
...
@@ -108,6 +99,27 @@ class TakePlaceService
...
@@ -108,6 +99,27 @@ class TakePlaceService
return
$data
;
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
];
}
/**
/**
* 添加自提点
* 添加自提点
* @param $params
* @param $params
...
@@ -118,7 +130,7 @@ class TakePlaceService
...
@@ -118,7 +130,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"
]]);
...
@@ -129,7 +141,7 @@ class TakePlaceService
...
@@ -129,7 +141,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'
];
...
@@ -139,6 +151,9 @@ class TakePlaceService
...
@@ -139,6 +151,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'
]
=
$params
[
'tag_id'
];
$data
[
'business_circle_id'
]
=
$params
[
'business_circle_id'
];
$data
[
'lunch_deliver_time'
]
=
$params
[
'lunch_deliver_time'
];
return
TakePlace
::
insert
(
$data
);
return
TakePlace
::
insert
(
$data
);
}
}
...
@@ -147,15 +162,16 @@ class TakePlaceService
...
@@ -147,15 +162,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
]
);
);
}
}
...
@@ -164,16 +180,17 @@ class TakePlaceService
...
@@ -164,16 +180,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
]);
}
}
...
@@ -194,12 +211,12 @@ class TakePlaceService
...
@@ -194,12 +211,12 @@ class TakePlaceService
$page
=
$params
[
'page'
]
??
1
;
$page
=
$params
[
'page'
]
??
1
;
$limit
=
$params
[
'limit'
]
??
20
;
$limit
=
$params
[
'limit'
]
??
20
;
$offset
=
(
$page
-
1
)
*
$limit
;
$offset
=
(
$page
-
1
)
*
$limit
;
$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,
...
@@ -214,23 +231,23 @@ class TakePlaceService
...
@@ -214,23 +231,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
;
}
}
...
@@ -245,17 +262,17 @@ class TakePlaceService
...
@@ -245,17 +262,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