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
119cd9f8
Commit
119cd9f8
authored
Dec 10, 2019
by
张晓林
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'development' of
http://gitlab-ebiz.yiyao365.cn/newshop/newshopback
into development
parents
e9625051
683a07f7
Changes
12
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
568 additions
and
85 deletions
+568
-85
urlmanager.php
backend/config/urlmanager.php
+2
-1
AuthorityNodeController.php
backend/controllers/v1/authority/AuthorityNodeController.php
+111
-10
ShopGoodsController.php
backend/controllers/v1/shopgoods/ShopGoodsController.php
+11
-0
O2oDeliveryController.php
backend/controllers/v1/transport/O2oDeliveryController.php
+39
-47
TransportInitialPriceController.php
...trollers/v1/transport/TransportInitialPriceController.php
+41
-12
ShopBranch.php
backend/models/v1/branch/ShopBranch.php
+1
-1
ShopCityDistributionRegion.php
backend/models/v1/branch/ShopCityDistributionRegion.php
+2
-4
ShopCityDistributionSetting.php
backend/models/v1/branch/ShopCityDistributionSetting.php
+31
-9
ShopRbacUser.php
backend/models/v1/rbacuser/ShopRbacUser.php
+1
-1
ShopGoods.php
backend/models/v1/shopgoods/ShopGoods.php
+251
-0
ScdsImport.php
backend/models/v1/transport/ScdsImport.php
+78
-0
o2o_delivery_import.xls
template/o2o_delivery_import.xls
+0
-0
No files found.
backend/config/urlmanager.php
View file @
119cd9f8
...
...
@@ -261,6 +261,7 @@ return [
'PUT,OPTIONS o2o-delivery-update'
=>
'o2o-delivery-update'
,
'GET,OPTIONS o2o-delivery-export'
=>
'o2o-delivery-export'
,
'GET,OPTIONS o2o-delivery-view'
=>
'o2o-delivery-view'
,
'POST,OPTIONS o2o-delivery-import'
=>
'o2o-delivery-import'
,
],
],
//配送方式
...
...
@@ -301,7 +302,7 @@ return [
'extraPatterns'
=>
[
'GET,OPTIONS node-list'
=>
'node-list'
,
'GET,OPTIONS node-details'
=>
'node-details'
,
'
put
,OPTIONS node-update'
=>
'node-update'
,
'
PUT
,OPTIONS node-update'
=>
'node-update'
,
'POST,OPTIONS node-add'
=>
'node-add'
,
'DELETE,OPTIONS node-del'
=>
'node-del'
,
]
...
...
backend/controllers/v1/authority/AuthorityNodeController.php
View file @
119cd9f8
...
...
@@ -142,14 +142,14 @@ class AuthorityNodeController extends BaseController
* @OA\Property(property="NAME" ,type="string", description="菜单地址"),
* @OA\Property(property="TITLE" ,type="string", description="菜单名称"),
* @OA\Property(property="LOGO" ,type="string",description="菜单前面的图标url"),
* @OA\Property(property="STATUS", type="int",description="菜单状态(默认1启用,0禁用)"),
* @OA\Property(property="IS_MENU", type="int",description="是否菜单(默认0否,1是)"),
* @OA\Property(property="IS_TOP_MENU", type="int",description="是否顶部菜单(默认0否,1是)"),
* @OA\Property(property="IS_DEFAULT_SHOW", type="int",description="是否进入默认显示页面(默认0否,1是)"),
* @OA\Property(property="STATUS", type="int",description="菜单状态(默认1启用,0禁用)"
,example="1"
),
* @OA\Property(property="IS_MENU", type="int",description="是否菜单(默认0否,1是)"
,example="0"
),
* @OA\Property(property="IS_TOP_MENU", type="int",description="是否顶部菜单(默认0否,1是)"
,example="0"
),
* @OA\Property(property="IS_DEFAULT_SHOW", type="int",description="是否进入默认显示页面(默认0否,1是)"
,example="0"
),
* @OA\Property(property="REMARK", type="string",description="描述"),
* @OA\Property(property="SORT", type="int",description="菜单排序序号"),
* @OA\Property(property="PID", type="string",description="父级菜单ID(默认无:0)"),
* @OA\Property(property="LEVEL",type="int",description="菜单层级等级(类型-0:项目,1:模块,2:操作)")
* @OA\Property(property="PID", type="string",description="父级菜单ID(默认无:0)"
,example="0"
),
* @OA\Property(property="LEVEL",type="int",description="菜单层级等级(类型-0:项目,1:模块,2:操作)"
,example="0"
)
* )
* )
* ),
...
...
@@ -192,9 +192,9 @@ class AuthorityNodeController extends BaseController
* summary="删除权限节点(侯贺政)",
* description="删除权限节点",
* @OA\Parameter(
* description="要删除的节点
GU
ID",
* description="要删除的节点ID",
* in="query",
* name="
GU
ID",
* name="ID",
* required=true,
* @OA\Schema(
* type="string",
...
...
@@ -209,9 +209,9 @@ class AuthorityNodeController extends BaseController
*/
public
function
actionNodeDel
()
{
$
guid
=
Yii
::
$app
->
request
->
get
(
'GU
ID'
);
$
id
=
Yii
::
$app
->
request
->
get
(
'
ID'
);
$model
=
new
$this
->
modelClass
();
$_model
=
$model
::
findOne
(
$
gu
id
);
$_model
=
$model
::
findOne
(
$id
);
if
(
!
$_model
)
{
throw
new
BadRequestHttpException
(
'Requested resource does not exist !'
);
}
...
...
@@ -221,4 +221,105 @@ class AuthorityNodeController extends BaseController
throw
new
HttpException
(
200
,
"删除成功!"
);
}
/**
* @OA\GET(
* path="/backend/web/v1/authority/authority-nodes/node-details",
* tags={"权限管理"},
* summary="权限节点详情(侯贺政)",
* description="权限节点详情",
* @OA\Parameter(
* description="节点ID",
* name="ID",
* in="query",
* @OA\Schema(
* type="string"
* )
* ),
* @OA\Response(
* response=200,
* description="
* ID:节点id,
* NAME:菜单地址,
* TITLE:菜单名称,
* LOGO:logo地址,
* STATUS:菜单状态 0禁用 1启用,
* IS_MENU:是否为菜单(1:是,0:不是),
* IS_TOP_MENU:是否顶部菜单 1是 0否,
* IS_DEFAULT_SHOW:是否进入默认显示页面 1是0否,
* REMARK:描述,
* SORT:菜单排序序号,
* PID:父级菜单ID,
* LEVEL:菜单层级等级(类型-0:项目,1:模块,2:操作)")
* ),
* security={{"Authorization":{}}}
* )
*/
public
function
actionNodeDetails
()
{
$id
=
Yii
::
$app
->
request
->
get
(
'ID'
);
$model
=
new
$this
->
modelClass
();
$info
=
$model
->
findOne
(
$id
);
if
(
!
$info
)
{
throw
new
BadRequestHttpException
(
'Requested resource does not exist !'
);
}
return
$info
;
}
/**
* @OA\PUT(
* path="/backend/web/v1/authority/authority-nodes/node-update",
* tags={"权限管理"},
* summary="更新权限节点(侯贺政)",
* description="更新权限节点",
* @OA\RequestBody(
* required=true,
* description="权限节点更新",
* @OA\MediaType(
* mediaType="application/x-www-form-urlencoded",
* @OA\Schema(
* type="object",
* required={"ID"},
* @OA\Property(property="ID",type="int",description="节点ID"),
* @OA\Property(property="NAME" ,type="string", description="菜单地址"),
* @OA\Property(property="TITLE" ,type="string", description="菜单名称"),
* @OA\Property(property="LOGO" ,type="string",description="菜单前面的图标url"),
* @OA\Property(property="STATUS", type="int",description="菜单状态(1启用,0禁用)"),
* @OA\Property(property="IS_MENU", type="int",description="是否菜单(0否,1是)"),
* @OA\Property(property="IS_TOP_MENU", type="int",description="是否顶部菜单(0否,1是)"),
* @OA\Property(property="IS_DEFAULT_SHOW", type="int",description="是否进入默认显示页面(0否,1是)"),
* @OA\Property(property="REMARK", type="string",description="描述"),
* @OA\Property(property="SORT", type="int",description="菜单排序序号"),
* @OA\Property(property="PID", type="string",description="父级菜单ID(无:0)"),
* @OA\Property(property="LEVEL",type="int",description="菜单层级等级(类型-0:项目,1:模块,2:操作)")
* )
* )
* ),
* @OA\Response(response=200,description="更新成功!"),
* security={{"Authorization":{}}}
* )
*/
public
function
actionNodeUpdate
()
{
$params
=
Yii
::
$app
->
request
->
bodyParams
;
$model
=
new
$this
->
modelClass
();
$_model
=
$model
::
findOne
(
$params
[
'ID'
]);
if
(
!
$_model
)
{
throw
new
BadRequestHttpException
(
"不存在此节点!"
);
}
//过滤掉部分为空的参数
foreach
(
$params
as
$key
=>
$value
)
{
if
(
in_array
(
$key
,
[
'TITLE'
,
'STATUS'
,
'IS_MENU'
,
'IS_TOP_MENU'
,
'IS_DEFAULT_SHOW'
,
'SORT'
,
'PID'
,
'LEVEL'
])
&&
empty
(
trim
(
$value
)))
{
unset
(
$params
[
$key
]);
}
}
$_model
->
attributes
=
$params
;
if
(
!
$_model
->
save
())
{
Yii
::
$app
->
response
->
statusCode
=
422
;
return
$_model
->
errors
;
}
throw
new
HttpException
(
200
,
'更新成功!'
);
}
}
backend/controllers/v1/shopgoods/ShopGoodsController.php
0 → 100644
View file @
119cd9f8
<?php
namespace
backend\controllers\v1\goods
;
use
Yii
;
use
backend\controllers\v1\BaseController
;
class
ShopGoodsController
extends
BaseController
{
public
$modelClass
=
'app\models\v1\goods\ShopGoods'
;
}
\ No newline at end of file
backend/controllers/v1/transport/O2oDeliveryController.php
View file @
119cd9f8
...
...
@@ -11,6 +11,7 @@ use yii\web\HttpException;
use
backend\helpers\UploadFiles
;
use
yii\web\UploadedFile
;
use
yidas\phpSpreadsheet\Helper
;
use
app\models\v1\transport\ScdsImport
;
class
O2oDeliveryController
extends
BaseController
{
...
...
@@ -244,6 +245,7 @@ class O2oDeliveryController extends BaseController
*/
public
function
actionO2oDeliveryImport
()
{
$scdsImport
=
new
ScdsImport
();
$model
=
new
UploadFiles
();
if
(
Yii
::
$app
->
request
->
isPost
)
{
//多文件用getInstances
...
...
@@ -254,63 +256,53 @@ class O2oDeliveryController extends BaseController
if
(
$fileInfo
[
'CODE'
]
==
200
)
{
$rows
=
Helper
::
newSpreadsheet
(
$fileInfo
[
'INFO'
][
0
])
->
getRows
();
$tempArr
=
array_slice
(
$rows
,
2
);
$scdrModel
=
new
ShopCityDistributionRegion
();
$scdsModel
=
new
$this
->
modelClass
();
$scdsModel
->
scenario
=
'o2o_import'
;
//判断用户等级
$rbacModel
=
new
ShopRbacUser
();
$userGuid
=
Yii
::
$app
->
user
->
identity
->
GUID
;
$userInfo
=
$rbacModel
->
getRbacUserInfo
(
$userGuid
);
switch
(
$userInfo
[
'ROLE_ID'
])
{
case
USER_ROLE_HEADQUARTERS_ADMIN
:
break
;
case
USER_ROLE_REGION_ADMIN
:
break
;
case
USER_ROLE_STORE_ADMIN
:
break
;
$codeArr
=
[];
$scdsImport
->
scenario
=
'o2o_update'
;
foreach
(
$tempArr
as
$keyA
=>
$valueA
)
{
$codeArr
[]
=
$valueA
[
0
];
}
$transaction
=
$scdsModel
->
getDb
()
->
beginTransaction
();
try
{
foreach
(
$tempArr
as
$key
=>
$value
)
{
$_scdsModel
=
$scdsModel
::
find
()
->
where
([
'BRANCH_GUID'
=>
Yii
::
$app
->
user
->
identity
->
ORG_GUID
.
'-'
.
$value
[
0
],
'SETTING_TYPE'
=>
O2O_FLAG
]);
if
(
$_scdsModel
===
null
)
{
$_scdsModel
=
clone
$scdsModel
;
}
$_scdsModel
->
BRANCH_CODE
=
$value
[
0
];
$_scdsModel
->
REGION_TYPE
=
$value
[
1
];
$_scdsModel
->
DELIVERY_PRICE
=
$value
[
2
];
$_scdsModel
->
REGION_DISTR_DISTANCE
=
$value
[
3
];
$_scdsModel
->
REGION_DISTR_PRICE
=
$value
[
4
];
$_scdsModel
->
INCREASE_DISTANCE
=
$value
[
5
];
$_scdsModel
->
INCREASE_PRICE
=
$value
[
6
];
if
(
$_scdsModel
->
REGION_TYPE
==
1
)
{
$_scdrModel
=
$scdrModel
::
find
()
->
where
([
'$_scdsModel'
=>
$_scdsModel
->
GUID
]);
if
(
$_scdrModel
===
null
)
{
$_scdrModel
=
clone
$scdrModel
;
$scdsImport
->
branchCodeArr
=
$codeArr
;
if
(
!
$scdsImport
->
validate
()){
return
$scdsImport
->
errors
;
}
// $_scdrModel ->
if
(
!
$_scdsModel
->
save
()
||
$_scdrModel
->
save
(
false
))
{
$transaction
->
rollBack
();
$transaction
=
$scdsImport
->
getDb
()
->
beginTransaction
();
$orgGuid
=
Yii
::
$app
->
user
->
identity
->
ORG_GUID
;
try
{
foreach
(
$tempArr
as
$key
=>
$valueB
)
{
$scdsImport
->
branchCode
=
$valueB
[
0
];
$scdsImport
->
REGION_TYPE
=
$valueB
[
1
];
$scdsImport
->
DELIVERY_PRICE
=
$valueB
[
2
];
$scdsImport
->
REGION_DISTR_DISTANCE
=
$valueB
[
3
];
$scdsImport
->
REGION_DISTR_PRICE
=
$valueB
[
4
];
$scdsImport
->
INCREASE_DISTANCE
=
$valueB
[
5
];
$scdsImport
->
INCREASE_PRICE
=
$valueB
[
6
];
if
(
!
$scdsImport
->
validate
()){
$returnInfo
=
[
(
$key
+
1
)
=>
$_scdsModel
->
errors
(
$key
+
1
)
=>
$scdsImport
->
errors
];
@
unlink
(
$fileInfo
[
'INFO'
][
0
]);
Yii
::
$app
->
response
->
statusCode
=
422
;
return
$returnInfo
;
# code...
return
$returnInfo
;
}
else
{
if
(
$scdsImport
->
REGION_TYPE
==
REGION_TYPE_REGION
)
{
//区域更新shop_city_distribution_setting和shop_city_distribution_region俩表
// $scdsImport->update();
$scdsImport
::
updateAll
([
'status'
=>
1
],
[
'status'
=>
$orgGuid
.
'-'
.
$scdsImport
->
branchCode
,
'SETTING_TYPE'
=>
O2O_FLAG
]);
}
elseif
(
$scdsImport
->
REGION_TYPE
==
REGION_TYPE_DISTANCE
){
//距离更新shop_city_distribution_setting表
}
}
elseif
(
$_scdsModel
->
REGION_TYPE
==
2
){
}
}
$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/TransportInitialPriceController.php
View file @
119cd9f8
...
...
@@ -14,6 +14,7 @@ use backend\helpers\Func;
use
yii\web\HttpException
;
use
app\models\v1\rbacuser\ShopRbacUser
;
use
app\models\v1\branch\ShopBranch
;
use
app\models\v1\branch\ShopCityDistributionSetting
;
class
TransportInitialPriceController
extends
BaseController
{
...
...
@@ -46,18 +47,17 @@ class TransportInitialPriceController extends BaseController
*/
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
=
new
ShopCityDistributionRegion
();
$params
=
Yii
::
$app
->
request
->
queryParams
;
//当前权限允许的区域GUID
$guids
=
$this
->
getRegionGuid
(
$userinfo
);
$params
[
'REGION_GUID'
]
=
$guids
;
$model
->
attributes
=
$params
;
if
(
$model
->
validate
())
{
//所有输入数据都有效 all inputs are valid
...
...
@@ -72,6 +72,36 @@ class TransportInitialPriceController extends BaseController
return
$model
->
errors
;
}
}
/**
* 获取符合权限的优惠券
* @param $userinfo 用户权限信息
*/
public
function
getRegionGuid
(
$userinfo
)
{
$city_dis_setting
=
new
ShopCityDistributionSetting
();
//省级管理员的优惠券
if
(
$userinfo
[
'ROLE_ID'
])
{
$branch_guid
=
$userinfo
[
'BRANCH_GUID'
];
if
(
$branch_guid
)
{
$userbranch
=
$city_dis_setting
->
getInitialCoupon
(
$branch_guid
,
$userinfo
[
'ROLE_ID'
]);
//去掉重复的
$userbranchcouponguid
=
array
();
if
(
$userbranch
)
{
foreach
(
$userbranch
as
$k1
=>
$v1
)
{
$userbranchcouponguid
[]
=
$v1
[
'GUID'
];
}
}
if
(
!
$userbranchcouponguid
)
{
$userbranchcouponguid
=
""
;
}
return
$userbranchcouponguid
;
}
else
{
return
''
;
}
}
else
{
return
''
;
}
}
/**
* @OA\PUT(
* path="/backend/web/v1/transport/transport-initial-prices/revise-initial-price",
...
...
@@ -160,19 +190,18 @@ class TransportInitialPriceController extends BaseController
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);
// $_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
)
{
if
(
$userinfo
[
'ROLE_ID'
]
==
USER_ROLE_REGION_ADMIN
)
{
//如果是省级,查询出该门店是否是该省级下的
$branchModel
=
new
ShopBranch
();
// $userinfo['BRANCH_GUID'] = 003;
$isbrancharr
=
$branchModel
->
GetBranch
(
$CS_BRANCH_GUID
,
$userinfo
[
'BRANCH_GUID'
]);
// $isbrancharr = $branchModel->GetBranch(003, 003);
if
(
!
$isbrancharr
)
{
continue
;
}
...
...
backend/models/v1/branch/ShopBranch.php
View file @
119cd9f8
...
...
@@ -50,7 +50,7 @@ use app\models\v1\rbacuser\ShopRbacUser;
* @property string $TRANSFERS_OPENID 收款人openid
* @property int $IS_SHELVE 是否营业
* @property string $LICENCE_DATE 营业执照到期时间
* @property int $BRANCH_TYPE 部门类型,0:总部 1:省级DC分公司 2:
区域 3:
门店
* @property int $BRANCH_TYPE 部门类型,0:总部 1:省级DC分公司 2:门店
* @property string $SUPPORT_SEND_PLATFORM 支持配送的平台:(1.达达,2蜂鸟,3美团) 按顺序逗号分隔
* @property string $TRANSPORT_TYPE 快递类型
* @property int $IS_DELIVERY_CODECHAIN_GOODS 1:支持冷链配送,0:不支持
...
...
backend/models/v1/branch/ShopCityDistributionRegion.php
View file @
119cd9f8
...
...
@@ -98,10 +98,8 @@ class ShopCityDistributionRegion extends BaseModel
$query
->
andfilterWhere
([
'or'
,
[
'like'
,
'sb.CODE'
,
$params
[
'CODE'
]],
[
'like'
,
'sb.NAME'
,
$params
[
'CODE'
]]]);
}
//当前权限允许的门店
if
(
isset
(
$params
[
'BRANCH_GUID'
])
&&
!
empty
(
$params
[
'BRANCH_GUID'
]))
{
$query
->
andFilterWhere
([
'or'
,
[
'='
,
'ifnull(sb.SUPPROVINCE_GUID,cs.BRANCH_GUID)'
,
$params
[
'BRANCH_GUID'
]],
[
'='
,
"ifnull(sb.PARENT_GUID,'')"
,
$params
[
'BRANCH_GUID'
]]]);
//$query->andWhere(['not', ['sg.GUID' => '']]);
$query
->
andWhere
([
'!='
,
'sg.GUID'
,
''
]);
if
(
isset
(
$params
[
'REGION_GUID'
])
&&
!
empty
(
$params
[
'REGION_GUID'
]))
{
$query
->
andFilterWhere
([
'sg.GUID'
=>
$params
[
'REGION_GUID'
]]);
}
//批量修改 条件
if
(
isset
(
$guid
)
&&
!
empty
(
$guid
))
{
...
...
backend/models/v1/branch/ShopCityDistributionSetting.php
View file @
119cd9f8
...
...
@@ -62,17 +62,17 @@ class ShopCityDistributionSetting extends BaseModel
[[
'ORG_GUID'
,
'GUID'
,
'BRANCH_GUID'
,
'REGION_TYPE'
,
'SETTING_TYPE'
],
'required'
,
'on'
=>
[
'insert'
,
'update'
]],
[[
'STATUS'
],
'boolean'
],
[[
'REGION_TYPE'
,
'SETTING_TYPE'
],
'in'
,
'range'
=>
[
1
,
2
],
'on'
=>
[
'insert'
,
'update'
]
],
[[
'REGION_TYPE'
,
'SETTING_TYPE'
],
'in'
,
'range'
=>
[
1
,
2
],
'on'
=>
[
'insert'
,
'update'
,
'o2o_update'
],
'message'
=>
'{attribute}只能为1或2'
],
[[
'BRANCH_GUID'
],
'exist'
,
'skipOnError'
=>
true
,
'targetClass'
=>
ShopBranch
::
className
(),
'targetAttribute'
=>
[
'BRANCH_GUID'
=>
'GUID'
]],
[[
'BRANCH_INFO'
],
'match'
,
'pattern'
=>
'/^[\x{4e00}-\x{9fa5}A-Za-z0-9_]+$/u'
,
'message'
=>
'只能包含中文汉字,字母,数字'
,
'on'
=>
'search'
],
[[
'
GUID'
,
'REGION_TYPE'
],
'required'
,
'on'
=>
[
'o2o_update'
],
'message'
=>
'{attribute}不能为空'
],
[[
'REGION_DISTR_DISTANCE'
,
'REGION_DISTR_PRICE'
,
'INCREASE_DISTANCE'
,
'INCREASE_PRICE'
,
'DELIVERY_PRICE'
],
'double'
,
'on'
=>
[
'o2o_update'
]],
[[
'REGION_DISTR_DISTANCE'
,
'REGION_DISTR_PRICE'
,
'INCREASE_DISTANCE'
,
'INCREASE_PRICE'
],
'required'
,
'when'
=>
function
(
$model
)
{
[[
'BRANCH_INFO'
],
'match'
,
'pattern'
=>
'/^[\x{4e00}-\x{9fa5}A-Za-z0-9_]+$/u'
,
'message'
=>
'只能包含中文汉字,字母,数字'
,
'on'
=>
'search'
],
[[
'
REGION_TYPE'
],
'required'
,
'on'
=>
[
'o2o_update'
],
'message'
=>
'{attribute}不能为空'
],
[[
'REGION_DISTR_DISTANCE'
,
'REGION_DISTR_PRICE'
,
'INCREASE_DISTANCE'
,
'INCREASE_PRICE'
,
'DELIVERY_PRICE'
],
'double'
,
'on'
=>
[
'o2o_update'
]],
[[
'REGION_DISTR_DISTANCE'
,
'REGION_DISTR_PRICE'
,
'INCREASE_DISTANCE'
,
'INCREASE_PRICE'
],
'required'
,
'when'
=>
function
(
$model
)
{
return
$model
->
REGION_TYPE
==
'2'
;
},
'message'
=>
'{attribute}不能为空'
,
'on'
=>
[
'o2o_update'
]],
[[
'DELIVERY_PRICE'
],
'required'
,
'when'
=>
function
(
$model
)
{
},
'message'
=>
'费用类型为2时,{attribute}不能为空'
,
'on'
=>
[
'o2o_update'
]],
[[
'DELIVERY_PRICE'
],
'required'
,
'when'
=>
function
(
$model
)
{
return
$model
->
REGION_TYPE
==
'1'
;
},
'message'
=>
'{attribute}不能为空'
,
'on'
=>
[
'o2o_update'
]],
},
'message'
=>
'费用类型为1时,{attribute}不能为空'
,
'on'
=>
[
'o2o_update'
]],
];
}
...
...
@@ -90,7 +90,7 @@ class ShopCityDistributionSetting extends BaseModel
'IS_OTHER_DISTR'
=>
'Is Other Distr'
,
'WORK_TYPE'
=>
'Work Type'
,
'IS_DADA_DISTR'
=>
'Is Dada Distr'
,
'REGION_TYPE'
=>
'
配送
类型'
,
'REGION_TYPE'
=>
'
费用
类型'
,
'SIMPLE_DISTR_NOTES'
=>
'Simple Distr Notes'
,
'SIMPLE_DISTR_PIC'
=>
'Simple Distr Pic'
,
'SIMPLE_DISTR_INITIAL_PRICE'
=>
'Simple Distr Initial Price'
,
...
...
@@ -296,4 +296,26 @@ class ShopCityDistributionSetting extends BaseModel
$branch_info
[
'B2C'
]
=
$b2c
;
return
$branch_info
;
}
//获取起送价优惠
public
function
getInitialCoupon
(
$branch_guid
,
$role_id
)
{
$query
=
static
::
find
()
->
alias
(
'cs'
)
->
select
(
"sg.GUID,sb.SUPPROVINCE_GUID,sb.PARENT_GUID"
)
->
leftJoin
(
'SHOP_CITY_DISTRIBUTION_REGION sg'
,
'cs.GUID=sg.CITY_DISTR_GUID'
)
->
leftJoin
(
'SHOP_BRANCH sb'
,
'sb.GUID=cs.BRANCH_GUID'
)
->
where
([
'cs.SETTING_TYPE'
=>
2
]);
//当前权限允许的门店
if
(
isset
(
$branch_guid
)
&&
!
empty
(
$branch_guid
)
&&
$role_id
==
USER_ROLE_REGION_ADMIN
)
{
$query
->
andFilterWhere
([
'or'
,
[
'='
,
'ifnull(sb.SUPPROVINCE_GUID,cs.BRANCH_GUID)'
,
$branch_guid
],
[
'='
,
"ifnull(sb.PARENT_GUID,'')"
,
$branch_guid
]]);
$query
->
andWhere
([
'!='
,
'sg.GUID'
,
''
]);
return
$query
->
all
();
}
elseif
(
isset
(
$branch_guid
)
&&
!
empty
(
$branch_guid
)
&&
$role_id
==
USER_ROLE_STORE_ADMIN
)
{
$query
->
andFilterWhere
([
"ifnull(cs.BRANCH_GUID,'')"
=>
$branch_guid
]);
$query
->
andWhere
([
'!='
,
'sg.GUID'
,
''
]);
return
$query
->
all
();
}
else
{
return
''
;
}
}
}
backend/models/v1/rbacuser/ShopRbacUser.php
View file @
119cd9f8
...
...
@@ -15,7 +15,7 @@ use backend\helpers\Func;
* @property string $NAME 姓名
* @property string $PASSWORD 密码
* @property string $ORG_GUID 组织机构号
* @property string $BRANCH_GUID
如果USERGROUPGUID是店长或省级管理员,
用来存门店GUID或省级GUID
* @property string $BRANCH_GUID 用来存门店GUID或省级GUID
* @property string $CREATE_GUID 创建人GUID
* @property string $CREATE_NAME 创建人姓名
* @property string $CREATE_DATE 创建时间
...
...
backend/models/v1/shopgoods/ShopGoods.php
0 → 100644
View file @
119cd9f8
This diff is collapsed.
Click to expand it.
backend/models/v1/transport/ScdsImport.php
0 → 100644
View file @
119cd9f8
<?php
namespace
app\models\v1\transport
;
use
app\models\v1\rbacuser\ShopRbacUser
;
use
Yii
;
use
app\models\v1\branch\ShopCityDistributionSetting
;
use
yii\web\HttpException
;
class
ScdsImport
extends
ShopCityDistributionSetting
{
//用来导入数据时使用
public
$branchCodeArr
=
[];
//门店code数组
public
$branchCode
=
''
;
//门店code
/**
* {@inheritdoc}
*/
public
function
rules
()
{
$sonRules
=
[
[[
'branchCodeArr'
],
'validateEffective'
],
[[
'branchCode'
],
'required'
,
'message'
=>
'{attribute}不能为空'
],
];
return
array_merge
(
parent
::
rules
(),
$sonRules
);
}
public
function
attributeLabels
()
{
$sonAttri
=
[
'branchCode'
=>
'门店编码'
];
return
array_merge
(
parent
::
attributeLabels
(),
$sonAttri
);
}
//验证用户有没有权限修改导入门店电子围栏信息
public
function
validateEffective
(
$attribute
)
{
$rbacUserModel
=
new
ShopRbacUser
();
$userGuid
=
Yii
::
$app
->
user
->
identity
->
GUID
;
$userInfo
=
$rbacUserModel
->
getRbacUserInfo
(
$userGuid
);
switch
(
$userInfo
[
'BRANCH_TYPE'
])
{
case
BRANCH_TYPE_HEADQUARTERS
://
总部
$branchGuid
=
''
;
$parentGuid
=
''
;
break
;
case
BRANCH_TYPE_REGION
://
省级
/
分公司
$branchGuid
=
$userInfo
[
'BRANCH_GUID'
];
$parentGuid
=
$userInfo
[
'BRANCH_GUID'
];
break
;
case
BRANCH_TYPE_STORE
://
门店
$branchGuid
=
$userInfo
[
'BRANCH_GUID'
];
$parentGuid
=
''
;
break
;
default
:
throw
new
HttpException
(
500
,
'不存在的门店等级'
);
break
;
}
$codeArr
=
$this
::
find
()
->
select
(
'CODE'
)
->
from
(
'SHOP_BRANCH'
)
->
where
([
'CODE'
=>
$this
->
branchCodeArr
])
->
andFilterWhere
([
'or'
,[
'GUID'
=>
$branchGuid
],[
'PARENT_GUID'
=>
$parentGuid
]])
->
asArray
()
->
all
();
$tempArr
=
[];
foreach
(
$codeArr
as
$value
)
{
$tempArr
[]
=
$value
[
'CODE'
];
}
$diff
=
array_diff
(
$this
->
branchCodeArr
,
$tempArr
);
if
(
!
empty
(
$diff
))
{
$this
->
addError
(
$attribute
,
'门店编码为'
.
implode
(
','
,
$diff
)
.
'的门店不存在或者您没有权限操作此门店.'
);
}
}
}
template/o2o_delivery_import.xls
View file @
119cd9f8
No preview for this file type
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