Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
newShopBack
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
newshop
newShopBack
Commits
541ff6a5
Commit
541ff6a5
authored
Nov 27, 2019
by
姚书霞
🐘
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
电子围栏重写导出
parent
73881abb
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
136 additions
and
73 deletions
+136
-73
urlmanager.php
backend/config/urlmanager.php
+1
-0
CityDistributionSettingController.php
...ntrollers/v1/branch/CityDistributionSettingController.php
+129
-7
ShopBranch.php
backend/models/v1/branch/ShopBranch.php
+4
-3
ShopCityDistributionSetting.php
backend/models/v1/branch/ShopCityDistributionSetting.php
+2
-63
No files found.
backend/config/urlmanager.php
View file @
541ff6a5
...
...
@@ -142,6 +142,7 @@ return [
],
'extraPatterns'
=>
[
'GET,OPTIONS city-distribution-setting-list'
=>
'city-distribution-setting-list'
,
'GET,OPTIONS city-distribution-setting-export'
=>
'city-distribution-setting-export'
,
'GET,OPTIONS city-distribution-setting-detail'
=>
'city-distribution-setting-detail'
,
'POST,OPTIONS city-distribution-setting-save'
=>
'city-distribution-setting-save'
,
'DELETE,OPTIONS city-distribution-setting-delete'
=>
'city-distribution-setting-delete'
,
...
...
backend/controllers/v1/branch/CityDistributionSettingController.php
View file @
541ff6a5
...
...
@@ -7,6 +7,8 @@ use backend\controllers\v1\BaseController;
use
backend\helpers\Func
;
use
yii\web\BadRequestHttpException
;
use
yii\web\ServerErrorHttpException
;
use
yii\data\ActiveDataProvider
;
use
yidas\phpSpreadsheet\Helper
;
class
CityDistributionSettingController
extends
BaseController
{
...
...
@@ -26,7 +28,6 @@ class CityDistributionSettingController extends BaseController
* @OA\Parameter(in = "query",name = "o2o_issetting",description = "是否设置020(1是 0否)",required = false,@OA\Schema(type="string")),
* @OA\Parameter(in = "query",name = "page",description = "分页页码",required = false,@OA\Schema(type="string")),
* @OA\Parameter(in = "query",name = "pageSize",description = "分页大小",required = false,@OA\Schema(type="string")),
* @OA\Parameter(in = "query",name = "export",description = "是否导出 传1生效 导出则分页设置不管用",required = false,@OA\Schema(type="string")),
* @OA\Response(response="200",description="
* GUID:门店GUID,
* CODE:门店CODE,
...
...
@@ -36,6 +37,8 @@ class CityDistributionSettingController extends BaseController
* NAME:门店名称,
* PHONE:门店联系电话,
* ADDRESS:门店地址
* LAT:经纬度
* LNG:经纬度
* B2C_ISSETTING:是否设置B2C
* 020_ISSETTING:是否设置020
* "),
...
...
@@ -47,12 +50,91 @@ class CityDistributionSettingController extends BaseController
{
$params
=
Yii
::
$app
->
getRequest
()
->
get
();
$model
=
new
$this
->
modelClass
();
$result
=
$model
->
getList
(
$params
);
$query
=
$model
->
getList
(
$params
);
$result
=
new
ActiveDataProvider
(
[
'query'
=>
$query
,
'pagination'
=>
[
'pageSize'
=>
$params
[
'pageSize'
]
??
20
,
]
]
);
//处理数据
$branch_list
=
$result
->
getModels
();
foreach
(
$branch_list
as
$key
=>&
$value
){
if
(
strstr
(
$value
[
'SETTING_TYPES'
],
'1'
)){
$value
[
'B2C_ISSETTING'
]
=
'是'
;
}
else
{
$value
[
'B2C_ISSETTING'
]
=
'否'
;
}
if
(
strstr
(
$value
[
'SETTING_TYPES'
],
'2'
)){
$value
[
'020_ISSETTING'
]
=
'是'
;
}
else
{
$value
[
'020_ISSETTING'
]
=
'否'
;
}
unset
(
$value
[
'SETTING_TYPES'
]);
}
$result
->
setModels
(
$branch_list
);
return
$result
;
}
/**
* @OA\Get(
* path="/backend/web/v1/branch/city-distribution-settings/city-distribution-setting-export",
* tags={"门店&DC"},
* summary="电子围栏列表导出u(姚书侠)",
* description="电子围栏列表导出接口",
* @OA\Parameter(in = "query",name = "code",description = "门店编码",required = false,@OA\Schema(type="string")),
* @OA\Parameter(in = "query",name = "province",description = "省份",required = false,@OA\Schema(type="string")),
* @OA\Parameter(in = "query",name = "city",description = "城市",required = false,@OA\Schema(type="string")),
* @OA\Parameter(in = "query",name = "region",description = "县区",required = false,@OA\Schema(type="string")),
* @OA\Parameter(in = "query",name = "b2c_issetting",description = "是否设置B2C(1是 0否)",required = false,@OA\Schema(type="string")),
* @OA\Parameter(in = "query",name = "o2o_issetting",description = "是否设置020(1是 0否)",required = false,@OA\Schema(type="string")),
* @OA\Response(response="200",description=""),
* security={{"Authorization": {}}}
* )
*/
//重写index
public
function
actionCityDistributionSettingExport
()
{
$params
=
Yii
::
$app
->
getRequest
()
->
get
();
$model
=
new
$this
->
modelClass
();
$query
=
$model
->
getList
(
$params
);
$result
=
$query
->
all
();
$export_result
=
[];
foreach
(
$result
as
$key
=>&
$value
){
$export
=
array
(
$value
[
'NAME'
],
$value
[
'PROVINCE'
],
$value
[
'CITY'
],
$value
[
'REGION'
],
$value
[
'PHONE'
],
$value
[
'ADDRESS'
]
);
if
(
strstr
(
$value
[
'SETTING_TYPES'
],
'1'
)){
$export
[
'B2C_ISSETTING'
]
=
'是'
;
}
else
{
$export
[
'B2C_ISSETTING'
]
=
'否'
;
}
if
(
strstr
(
$value
[
'SETTING_TYPES'
],
'2'
)){
$export
[
'020_ISSETTING'
]
=
'是'
;
}
else
{
$export
[
'020_ISSETTING'
]
=
'否'
;
}
array_push
(
$export_result
,
$export
);
}
unset
(
$result
);
Helper
::
newSpreadsheet
()
->
addRow
([
'门店名称'
,
'省'
,
'市'
,
'区/县'
,
'电话'
,
'门店地址'
,
'是否设置O2O围栏'
,
'是否设置B2C围栏'
])
->
addRows
(
$export_result
)
->
output
(
"门店电子围栏"
,
"Csv"
);
}
/**
* @OA\Get(
* path="/backend/web/v1/branch/city-distribution-settings/city-distribution-setting-detail",
* tags={"门店&DC"},
* summary="电子围栏详情(姚书侠)",
...
...
@@ -72,12 +154,22 @@ class CityDistributionSettingController extends BaseController
}
/**
* @OA\
Get
(
* @OA\
POST
(
* path="/backend/web/v1/branch/city-distribution-settings/city-distribution-setting-save",
* tags={"门店&DC"},
* summary="电子围栏保存(姚书侠)",
* description="电子围栏保存接口",
* @OA\Parameter(name="guid",in="query",required=true,description="门店GUID",@OA\Schema(type="string")),
* @OA\RequestBody(
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* @OA\Property(property="TYPE",description = "保存类型(1:O2O,2:B2C)",type="string"),
* @OA\Property(property="BRANCH_GUID",description = "门店GUID",type="string"),
* @OA\Property(property="GUID",description = "O2O或者B2C的GUID",type="string"),
* example={"CODE": 1234567890, "PASSWORD": "123"}
* )
* )
* ),
* @OA\Response(response = 200,description = "success"),
* security={{"Authorization": {}}}
* )
...
...
@@ -85,10 +177,40 @@ class CityDistributionSettingController extends BaseController
//编辑用
public
function
actionCityDistributionSettingSave
()
{
$branchguid
=
Yii
::
$app
->
getRequest
()
->
get
(
'guid'
);
$guid
=
Yii
::
$app
->
getRequest
()
->
post
(
'BRANCH_GUID'
);
$guid
=
Yii
::
$app
->
getRequest
()
->
post
(
'O2O_GUID'
);
$guid
=
Yii
::
$app
->
getRequest
()
->
post
(
'TYPE'
);
$model
=
$this
->
modelClass
::
findOne
(
$guid
);
if
(
!
$model
){
throw
new
BadRequestHttpException
(
'没有找到记录'
);
}
$model
->
scenario
=
'update'
;
//创建的场景
$model
->
setAttributes
(
Yii
::
$app
->
getRequest
()
->
post
());
if
(
$model
->
save
()
===
false
&&
!
$model
->
hasErrors
())
{
throw
new
ServerErrorHttpException
(
'Failed to update the object for unknown reason.'
);
}
return
$model
;
$model
=
new
$this
->
modelClass
();
$result
=
$model
->
getDetail
(
$branchguid
);
return
$result
;
$model
->
scenario
=
'create'
;
//创建的场景
$other_param
=
array
(
'GUID'
=>
Func
::
create_guid
(),
'ORG_GUID'
=>
Yii
::
$app
->
user
->
identity
->
ORG_GUID
,
);
$model
->
setAttributes
(
$other_param
);
$model
->
setAttributes
(
Yii
::
$app
->
getRequest
()
->
post
());
if
(
$model
->
save
())
{
Yii
::
$app
->
getResponse
()
->
setStatusCode
(
201
);
}
elseif
(
!
$model
->
hasErrors
())
{
throw
new
ServerErrorHttpException
(
'Failed to create the object for unknown reason.'
);
}
return
$model
;
}
}
\ No newline at end of file
backend/models/v1/branch/ShopBranch.php
View file @
541ff6a5
...
...
@@ -6,6 +6,7 @@ use app\models\v1\BaseModel;
use
Yii
;
use
yii\data\ActiveDataProvider
;
use
yii\helpers\ArrayHelper
;
use
app\models\v1\branch\ShopCityDistributionSetting
;
/**
* This is the model class for table "shop_branch".
...
...
@@ -80,7 +81,7 @@ use yii\helpers\ArrayHelper;
* @property int $IS_B2C 是否B2C门店 1是
* @property int $TOTAL_VOLUME 门店销量
*
* @property
CityDistributionSetting[] $c
ityDistributionSettings
* @property
ShopCityDistributionSetting[] $shopC
ityDistributionSettings
*/
class
ShopBranch
extends
BaseModel
{
...
...
@@ -244,9 +245,9 @@ class ShopBranch extends BaseModel
/**
* @return \yii\db\ActiveQuery
*/
public
function
getCityDistributionSettings
()
public
function
get
Shop
CityDistributionSettings
()
{
return
$this
->
hasMany
(
CityDistributionSetting
::
className
(),
[
'BRANCH_GUID'
=>
'GUID'
]);
return
$this
->
hasMany
(
Shop
CityDistributionSetting
::
className
(),
[
'BRANCH_GUID'
=>
'GUID'
]);
}
/**
...
...
backend/models/v1/branch/ShopCityDistributionSetting.php
View file @
541ff6a5
...
...
@@ -4,9 +4,6 @@ namespace app\models\v1\branch;
use
Yii
;
use
app\models\v1\BaseModel
;
use
app\models\v1\branch\ShopBranch
;
use
yii\data\ActiveDataProvider
;
use
yidas\phpSpreadsheet\Helper
;
/**
* This is the model class for table "shop_city_distribution_setting".
...
...
@@ -124,7 +121,7 @@ class ShopCityDistributionSetting extends BaseModel
{
//根据条件查询门店
$branch_query
=
ShopBranch
::
find
()
->
alias
(
'sb'
)
->
select
(
"vwb.PROVINCE,vwb.CITY,vwb.REGION,sb.NAME,sb.PHONE,sb.GUID,sb.CODE,sb.ADDRESS,group_concat(cds.SETTING_TYPE) SETTING_TYPES "
)
->
select
(
"vwb.PROVINCE,vwb.CITY,vwb.REGION,sb.NAME,sb.PHONE,sb.GUID,sb.
LAT,sb.LNG,sb.
CODE,sb.ADDRESS,group_concat(cds.SETTING_TYPE) SETTING_TYPES "
)
->
leftJoin
(
'shop_city_distribution_setting as cds'
,
"cds.BRANCH_GUID=sb.GUID"
)
->
leftJoin
(
'VW_BRANCH_ADDRESS vwb'
,
'vwb.GUID=sb.GUID'
)
->
groupBy
(
'sb.GUID'
)
...
...
@@ -163,65 +160,7 @@ class ShopCityDistributionSetting extends BaseModel
}
}
//如果是导出
if
(
isset
(
$params
[
'export'
])
&&
$params
[
'export'
]
==
'1'
)
{
$result
=
$branch_query
->
all
();
$export_result
=
[];
foreach
(
$result
as
$key
=>&
$value
){
$export
=
array
(
$value
[
'NAME'
],
$value
[
'PROVINCE'
],
$value
[
'CITY'
],
$value
[
'REGION'
],
$value
[
'PHONE'
],
$value
[
'ADDRESS'
]
);
if
(
strstr
(
$value
[
'SETTING_TYPES'
],
'1'
)){
$export
[
'B2C_ISSETTING'
]
=
'是'
;
}
else
{
$export
[
'B2C_ISSETTING'
]
=
'否'
;
}
if
(
strstr
(
$value
[
'SETTING_TYPES'
],
'2'
)){
$export
[
'020_ISSETTING'
]
=
'是'
;
}
else
{
$export
[
'020_ISSETTING'
]
=
'否'
;
}
array_push
(
$export_result
,
$export
);
}
unset
(
$result
);
Helper
::
newSpreadsheet
()
->
addRow
([
'门店名称'
,
'省'
,
'市'
,
'区/县'
,
'电话'
,
'门店地址'
,
'是否设置O2O围栏'
,
'是否设置B2C围栏'
])
->
addRows
(
$export_result
)
->
output
(
"门店电子围栏"
,
"Csv"
);
exit
();
}
$result
=
new
ActiveDataProvider
(
[
'query'
=>
$branch_query
,
'pagination'
=>
[
'pageSize'
=>
$params
[
'pageSize'
]
??
20
,
]
]
);
//处理数据
$branch_list
=
$result
->
getModels
();
foreach
(
$branch_list
as
$key
=>&
$value
){
if
(
strstr
(
$value
[
'SETTING_TYPES'
],
'1'
)){
$value
[
'B2C_ISSETTING'
]
=
'是'
;
}
else
{
$value
[
'B2C_ISSETTING'
]
=
'否'
;
}
if
(
strstr
(
$value
[
'SETTING_TYPES'
],
'2'
)){
$value
[
'020_ISSETTING'
]
=
'是'
;
}
else
{
$value
[
'020_ISSETTING'
]
=
'否'
;
}
unset
(
$value
[
'SETTING_TYPES'
]);
}
$result
->
setModels
(
$branch_list
);
return
$result
;
return
$branch_query
;
}
/**
...
...
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