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
d76a41d5
Commit
d76a41d5
authored
Dec 02, 2019
by
姚书霞
🐘
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复电子围栏接口
parent
8ee77278
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
15 deletions
+8
-15
CityDistributionSettingController.php
...ntrollers/v1/branch/CityDistributionSettingController.php
+3
-9
ShopCityDistributionRegion.php
backend/models/v1/branch/ShopCityDistributionRegion.php
+4
-4
ShopCityDistributionSetting.php
backend/models/v1/branch/ShopCityDistributionSetting.php
+1
-2
No files found.
backend/controllers/v1/branch/CityDistributionSettingController.php
View file @
d76a41d5
...
@@ -235,7 +235,6 @@ class CityDistributionSettingController extends BaseController
...
@@ -235,7 +235,6 @@ class CityDistributionSettingController extends BaseController
if
(
!
$model
){
if
(
!
$model
){
throw
new
BadRequestHttpException
(
'没有找到记录'
);
throw
new
BadRequestHttpException
(
'没有找到记录'
);
}
}
$model
->
setAttributes
(
Yii
::
$app
->
getRequest
()
->
post
());
}
else
{
}
else
{
$model
=
$this
->
modelClass
::
findOne
([
'SETTING_TYPE'
=>
$setting_type
,
'BRANCH_GUID'
=>
$branch_guid
]);
$model
=
$this
->
modelClass
::
findOne
([
'SETTING_TYPE'
=>
$setting_type
,
'BRANCH_GUID'
=>
$branch_guid
]);
if
(
$model
){
if
(
$model
){
...
@@ -243,23 +242,19 @@ class CityDistributionSettingController extends BaseController
...
@@ -243,23 +242,19 @@ class CityDistributionSettingController extends BaseController
}
else
{
}
else
{
$model
=
new
$this
->
modelClass
();
$model
=
new
$this
->
modelClass
();
}
}
$model
->
setAttributes
(
Yii
::
$app
->
getRequest
()
->
post
());
$other_param
=
array
(
$other_param
=
array
(
'GUID'
=>
Func
::
create_guid
(),
'GUID'
=>
Func
::
create_guid
(),
'ORG_GUID'
=>
'100'
,
//Yii::$app->user->identity->ORG_GUID,
'ORG_GUID'
=>
'100'
,
//Yii::$app->user->identity->ORG_GUID,
);
);
$model
->
scenario
=
'update'
;
//创建的场景
$model
->
setAttributes
(
$other_param
,
false
);
// $model->attribute->GUID='123';
$model
->
attributes
=
$other_param
;
}
}
$region_model
=
new
ShopCityDistributionRegion
();
$region_model
=
new
ShopCityDistributionRegion
();
$model
->
setAttributes
(
Yii
::
$app
->
getRequest
()
->
post
());
//开启事务
//开启事务
$trans
=
$model
->
getDb
()
->
beginTransaction
();
$trans
=
$model
->
getDb
()
->
beginTransaction
();
try
{
try
{
//添加主表
//添加主表
print_r
(
$model
);
die
;
if
(
$model
->
save
()
===
false
){
if
(
$model
->
save
()
===
false
){
if
(
!
$model
->
hasErrors
()){
if
(
!
$model
->
hasErrors
()){
throw
new
ServerErrorHttpException
(
'Failed to update the object for unknown reason.'
);
throw
new
ServerErrorHttpException
(
'Failed to update the object for unknown reason.'
);
...
@@ -275,6 +270,7 @@ class CityDistributionSettingController extends BaseController
...
@@ -275,6 +270,7 @@ class CityDistributionSettingController extends BaseController
//传过来的数据全部新增
//传过来的数据全部新增
$region_value
=
[];
$region_value
=
[];
foreach
(
$region
as
$value
){
foreach
(
$region
as
$value
){
$region_model
->
scenario
=
'save'
;
//创建的场景
$region_model
->
setAttributes
(
$value
);
$region_model
->
setAttributes
(
$value
);
$other_param_region
=
array
(
$other_param_region
=
array
(
'GUID'
=>
Func
::
create_guid
(),
'GUID'
=>
Func
::
create_guid
(),
...
@@ -282,7 +278,6 @@ class CityDistributionSettingController extends BaseController
...
@@ -282,7 +278,6 @@ class CityDistributionSettingController extends BaseController
"CITY_DISTR_GUID"
=>
$model
->
GUID
,
"CITY_DISTR_GUID"
=>
$model
->
GUID
,
);
);
$region_model
->
setAttributes
(
$other_param_region
,
false
);
$region_model
->
setAttributes
(
$other_param_region
,
false
);
$region_model
->
scenario
=
'save'
;
//创建的场景
if
(
$region_model
->
validate
())
{
if
(
$region_model
->
validate
())
{
$region_value
[]
=
$region_model
->
getAttributes
([
"GUID"
,
"ORG_GUID"
,
"CITY_DISTR_GUID"
,
"SORT"
,
"COLORS"
,
"DIVIDE_TYPE"
,
"REGION_R"
,
"REGION_RANGE"
,
"INITIAL_PRICE"
,
"DELIVERY_PRICE"
]);
$region_value
[]
=
$region_model
->
getAttributes
([
"GUID"
,
"ORG_GUID"
,
"CITY_DISTR_GUID"
,
"SORT"
,
"COLORS"
,
"DIVIDE_TYPE"
,
"REGION_R"
,
"REGION_RANGE"
,
"INITIAL_PRICE"
,
"DELIVERY_PRICE"
]);
...
@@ -324,7 +319,6 @@ class CityDistributionSettingController extends BaseController
...
@@ -324,7 +319,6 @@ class CityDistributionSettingController extends BaseController
$guid
=
Yii
::
$app
->
getRequest
()
->
post
(
'GUID'
);
$guid
=
Yii
::
$app
->
getRequest
()
->
post
(
'GUID'
);
//删除所有门店ID下的电子围栏 数据库外键会删除region表
//删除所有门店ID下的电子围栏 数据库外键会删除region表
$res
=
$this
->
modelClass
::
deleteAll
([
"BRANCH_GUID"
=>
$guid
]);
$res
=
$this
->
modelClass
::
deleteAll
([
"BRANCH_GUID"
=>
$guid
]);
if
(
$res
===
false
)
{
if
(
$res
===
false
)
{
throw
new
ServerErrorHttpException
(
'Failed to delete the object for unknown reason.'
);
throw
new
ServerErrorHttpException
(
'Failed to delete the object for unknown reason.'
);
}
}
...
...
backend/models/v1/branch/ShopCityDistributionRegion.php
View file @
d76a41d5
...
@@ -42,7 +42,7 @@ class ShopCityDistributionRegion extends BaseModel
...
@@ -42,7 +42,7 @@ class ShopCityDistributionRegion extends BaseModel
[[
'GUID'
,
'SORT'
,
'COLORS'
,
'DIVIDE_TYPE'
,
'REGION_R'
,
'REGION_RANGE'
,
'INITIAL_PRICE'
,
'DELIVERY_PRICE'
],
'required'
,
'on'
=>
"save"
],
[[
'GUID'
,
'SORT'
,
'COLORS'
,
'DIVIDE_TYPE'
,
'REGION_R'
,
'REGION_RANGE'
,
'INITIAL_PRICE'
,
'DELIVERY_PRICE'
],
'required'
,
'on'
=>
"save"
],
[[
'DIVIDE_TYPE'
],
'in'
,
'range'
=>
[
1
,
2
],
'on'
=>
"save"
],
[[
'DIVIDE_TYPE'
],
'in'
,
'range'
=>
[
1
,
2
],
'on'
=>
"save"
],
[[
'SORT'
],
'integer'
],
[[
'SORT'
],
'integer'
],
[[
'REGION_RANGE'
],
'string'
],
[[
'REGION_RANGE'
,
'COLORS'
],
'string'
],
[[
'INITIAL_PRICE'
,
'DELIVERY_PRICE'
,
'REGION_R'
],
'double'
],
[[
'INITIAL_PRICE'
,
'DELIVERY_PRICE'
,
'REGION_R'
],
'double'
],
];
];
}
}
...
@@ -58,11 +58,11 @@ class ShopCityDistributionRegion extends BaseModel
...
@@ -58,11 +58,11 @@ class ShopCityDistributionRegion extends BaseModel
'CITY_DISTR_GUID'
=>
'City Distr Guid'
,
'CITY_DISTR_GUID'
=>
'City Distr Guid'
,
'SORT'
=>
'SORT'
,
'SORT'
=>
'SORT'
,
'COLORS'
=>
'Colors'
,
'COLORS'
=>
'Colors'
,
'DIVIDE_TYPE'
=>
'
Hf Type
'
,
'DIVIDE_TYPE'
=>
'
划分类型
'
,
'REGION_R'
=>
'Region R'
,
'REGION_R'
=>
'Region R'
,
'REGION_RANGE'
=>
'Region Range'
,
'REGION_RANGE'
=>
'Region Range'
,
'INITIAL_PRICE'
=>
'
Qs Price
'
,
'INITIAL_PRICE'
=>
'
起送价
'
,
'DELIVERY_PRICE'
=>
'
Ps Price
'
,
'DELIVERY_PRICE'
=>
'
配送价
'
,
'WEEK'
=>
'Week'
,
'WEEK'
=>
'Week'
,
'IS_TYPE'
=>
'Is Type'
,
'IS_TYPE'
=>
'Is Type'
,
];
];
...
...
backend/models/v1/branch/ShopCityDistributionSetting.php
View file @
d76a41d5
...
@@ -54,10 +54,9 @@ class ShopCityDistributionSetting extends BaseModel
...
@@ -54,10 +54,9 @@ class ShopCityDistributionSetting extends BaseModel
public
function
rules
()
public
function
rules
()
{
{
return
[
return
[
[[
'BRANCH_GUID'
,
'REGION_TYPE'
,
'SETTING_TYPE'
,],
'required'
],
[[
'
ORG_GUID'
,
'GUID'
,
'
BRANCH_GUID'
,
'REGION_TYPE'
,
'SETTING_TYPE'
,],
'required'
],
[[
'REGION_DISTR_DISTANCE'
,
'REGION_DISTR_PRICE'
,
'INCREASE_DISTANCE'
,
'INCREASE_PRICE'
],
'double'
],
[[
'REGION_DISTR_DISTANCE'
,
'REGION_DISTR_PRICE'
,
'INCREASE_DISTANCE'
,
'INCREASE_PRICE'
],
'double'
],
[[
'STATUS'
],
'boolean'
],
[[
'STATUS'
],
'boolean'
],
[[
'ORG_GUID'
,
'GUID'
],
'safe'
,
'on'
=>
'update'
],
[[
'REGION_TYPE'
,
'SETTING_TYPE'
],
'in'
,
'range'
=>
[
1
,
2
]],
[[
'REGION_TYPE'
,
'SETTING_TYPE'
],
'in'
,
'range'
=>
[
1
,
2
]],
[[
'BRANCH_GUID'
],
'exist'
,
'skipOnError'
=>
true
,
'targetClass'
=>
ShopBranch
::
className
(),
'targetAttribute'
=>
[
'BRANCH_GUID'
=>
'GUID'
]],
[[
'BRANCH_GUID'
],
'exist'
,
'skipOnError'
=>
true
,
'targetClass'
=>
ShopBranch
::
className
(),
'targetAttribute'
=>
[
'BRANCH_GUID'
=>
'GUID'
]],
];
];
...
...
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