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
51510c89
Commit
51510c89
authored
Dec 04, 2019
by
郭勇志
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'development' of
http://gitlab-ebiz.yiyao365.cn/newshop/newshopback
into development
parents
6f1e5966
13e67d28
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
219 additions
and
1 deletion
+219
-1
TransportInitialPriceController.php
...trollers/v1/transport/TransportInitialPriceController.php
+218
-0
TransportMethodController.php
...nd/controllers/v1/transport/TransportMethodController.php
+1
-1
No files found.
backend/controllers/v1/transport/TransportInitialPriceController.php
0 → 100644
View file @
51510c89
<?php
namespace
backend\controllers\v1\transport
;
use
Yii
;
use
backend\controllers\v1\BaseController
;
use
app\models\v1\branch\ShopCityDistributionRegion
;
use
yii\web\BadRequestHttpException
;
use
yii\web\ServerErrorHttpException
;
use
yii\web\UploadedFile
;
use
backend\helpers\UploadFiles
;
use
yidas\phpSpreadsheet\Helper
;
use
backend\helpers\Func
;
use
yii\web\HttpException
;
use
app\models\v1\rbacuser\ShopRbacUser
;
use
app\models\v1\branch\ShopBranch
;
class
TransportInitialPriceController
extends
BaseController
{
public
$modelClass
=
'app\models\v1\branch\ShopCityDistributionRegion'
;
/**
* @OA\Get(
* path="/backend/web/v1/transport/transport-initial-prices/initial-price-list",
* tags={"配送管理"},
* description="门店起送价列表",
* summary="O2O起送价列表(孙磊)",
* @OA\Parameter(name="page",in="query",description="分页页码",@OA\Schema(type="int")),
* @OA\Parameter(name="CODE",in="query",description="门店名称或编码",@OA\Schema(type="string")),
* @OA\Response(response="200",description="
* GUID:电子围栏GUID,
* REGION_TYPE:配送区域类型,
* REGION_DISTR_DISTANCE:不同距离不同配送费**公里内,
* REGION_DISTR_PRICE:不同距离不同配送费*公里内*元,
* INCREASE_DISTANCE:不同距离不同配送费增加*公里,
* INCREASE_PRICE:不同距离不同配送费增加*公里*元,
* STATUS:是否开启同城配送,1:是,
* DELIVERY_PRICE:配送价格,
* SETTING_TYPE:电子围栏类型:1:B2C范围,2:O2O范围,
* NAME:门店名称,
* CODE:门店编号,
* INITIAL_PRICE:起送价格,
* "),
* security={{"Authorization": {}}}
* )
*/
public
function
actionInitialPriceList
()
{
$model
=
new
ShopCityDistributionRegion
();
$params
=
Yii
::
$app
->
request
->
queryParams
;
//权限信息
$rbac
=
new
ShopRbacUser
();
$userGuid
=
Yii
::
$app
->
user
->
identity
->
GUID
;
$userinfo
=
$rbac
->
getRbacUserInfo
(
$userGuid
);
if
(
$userinfo
){
$params
[
'BRANCH_GUID'
]
=
$userinfo
[
'BRANCH_GUID'
];
}
else
{
$params
[
'BRANCH_GUID'
]
=
''
;
}
$params
[
'BRANCH_GUID'
]
=
003
;
$model
->
attributes
=
$params
;
if
(
$model
->
validate
())
{
//所有输入数据都有效 all inputs are valid
$info
=
$model
->
getBranchInitialPrice
(
$params
);
if
(
!
$info
->
getModels
())
{
throw
new
BadRequestHttpException
(
'未找到符合的门店起送价信息'
);
}
return
$info
;
}
else
{
//验证失败:$errors 是一个包含错误信息的数组
Yii
::
$app
->
response
->
statusCode
=
422
;
return
$model
->
errors
;
}
}
/**
* @OA\PUT(
* path="/backend/web/v1/transport/transport-initial-prices/revise-initial-price",
* tags={"配送管理"},
* summary="O2O起送价修改(孙磊)",
* description="修改门店起送价",
* @OA\RequestBody(
* required=true,
* @OA\MediaType(
* mediaType="application/x-www-form-urlencoded",
* @OA\Schema(
* type="object",
* @OA\Property(property="GUID",description="要修改的电子围栏GUID",type="string"),
* @OA\Property(property="INITIAL_PRICE",description="起送价格",type="float"),
* )
* )
* ),
* @OA\Response(response=202,description="门店起送价修改成功"),
* security={{"Authorization": {}}}
* )
*/
public
function
actionReviseInitialPrice
()
{
$param
=
Yii
::
$app
->
getRequest
()
->
post
();
$guid
=
$param
[
'GUID'
];
$model
=
$this
->
modelClass
::
findOne
(
$guid
);
if
(
!
$model
){
throw
new
BadRequestHttpException
(
'没有找到要修改的记录'
);
}
//门店起送价修改
$model
->
scenario
=
'update'
;
//创建的场景
$model
->
setAttributes
(
$param
);
if
(
$model
->
save
()
===
false
&&
!
$model
->
hasErrors
())
{
throw
new
ServerErrorHttpException
(
'Failed to update the object for unknown reason.'
);
}
Yii
::
$app
->
getResponse
()
->
setStatusCode
(
202
);
return
$model
;
}
/**
* @OA\Post(
* path="/backend/web/v1/transport/transport-initial-prices/initial-price-import",
* tags={"配送管理"},
* summary="O2O起送价批量修改Excel(孙磊)",
* operationId="uploadFile",
* @OA\Response(
* response=200,
* description="上传成功",
* ),
* security={{"Authorization":{}}},
* @OA\RequestBody(
* description="门店起送价上传Excel",
* @OA\MediaType(
* mediaType="multipart/form-data",
* @OA\Schema(
* type="object",
* @OA\Property(
* property="uploadFile",
* type="string",
* format="binary"
* ),
* )
* )
* )
* )
*/
public
function
actionInitialPriceImport
()
{
$model
=
new
UploadFiles
();
if
(
Yii
::
$app
->
request
->
isPost
)
{
//多文件用getInstances
$model
->
uploadFiles
=
UploadedFile
::
getInstance
(
$model
,
'uploadFile'
);
$fileInfo
=
$model
->
upload
();
if
(
$fileInfo
[
'CODE'
]
==
200
)
{
// 文件上传成功
$rows
=
Helper
::
newSpreadsheet
(
$fileInfo
[
'INFO'
][
0
])
->
getRows
();
$tempArr
=
array_slice
(
$rows
,
2
);
$citydisregion
=
new
$this
->
modelClass
();
$citydisregion
->
scenario
=
'import'
;
$transaction
=
$citydisregion
->
getDb
()
->
beginTransaction
();
try
{
foreach
(
$tempArr
as
$key
=>
$value
)
{
$CS_BRANCH_GUID
=
Yii
::
$app
->
user
->
identity
->
ORG_GUID
.
'-'
.
$value
[
0
];
$_citydisregion
=
$citydisregion
->
getBranchInitialPrice
(
''
,
$CS_BRANCH_GUID
);
// $_citydisregion = $citydisregion->getBranchInitialPrice('',003);
//权限信息
$rbac
=
new
ShopRbacUser
();
$userGuid
=
Yii
::
$app
->
user
->
identity
->
GUID
;
$userinfo
=
$rbac
->
getRbacUserInfo
(
$userGuid
);
//return $userinfo;
//判断当前账号是省级还是门店还是总部
if
(
$userinfo
[
'ROLE_ID'
]
==
USER_ROLE_HEADQUARTERS_ADMIN
||
$userinfo
[
'ROLE_ID'
]
==
USER_ROLE_REGION_ADMIN
){
//如果是省级,查询出该门店是否是该省级下的
$branchModel
=
new
ShopBranch
();
// $userinfo['BRANCH_GUID'] = 003;
$isbrancharr
=
$branchModel
->
GetBranch
(
$CS_BRANCH_GUID
,
$userinfo
[
'BRANCH_GUID'
]);
if
(
!
$isbrancharr
){
continue
;
}
}
else
if
(
$userinfo
[
'ROLE_ID'
]
==
USER_ROLE_STORE_ADMIN
){
//如果是门店
if
(
$userinfo
[
'BRANCH_GUID'
]
!=
$CS_BRANCH_GUID
){
continue
;
}
}
//修改已有的起送价设置
if
(
!
$list
=
$_citydisregion
->
getModels
()){
continue
;
}
else
{
//更新起送价
$GUID
=
$list
[
0
][
'GUID'
];
$_cdrModel
=
$citydisregion
::
findOne
([
'GUID'
=>
$GUID
]);
if
(
empty
(
$value
[
1
])){
$value
[
1
]
=
0
;
}
$_cdrModel
->
INITIAL_PRICE
=
$value
[
1
];
if
(
!
$_cdrModel
->
save
())
{
$transaction
->
rollBack
();
$returnInfo
=
[
(
$key
+
1
)
=>
$_cdrModel
->
errors
];
return
$returnInfo
;
}
}
}
$transaction
->
commit
();
@
unlink
(
$fileInfo
[
'INFO'
][
0
]);
throw
new
HttpException
(
"200"
,
'导入成功'
);
}
catch
(
\Throwable
$e
)
{
$transaction
->
rollBack
();
@
unlink
(
$fileInfo
[
'INFO'
][
0
]);
throw
$e
;
}
}
else
{
return
$fileInfo
[
'INFO'
];
}
}
}
}
backend/controllers/v1/transport/TransportMethodController.php
View file @
51510c89
...
...
@@ -138,7 +138,7 @@ class TransportMethodController extends BaseController{
* @OA\PUT(
* path="/backend/web/v1/transport/transport-methods/transport-method-update",
* tags={"配送管理"},
* summary="
添加
配送方式(张晓林)",
* summary="
更新
配送方式(张晓林)",
* description="添加配送方式",
* * @OA\RequestBody(
* required=true,
...
...
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