Commit 043d58f2 authored by 孙磊's avatar 孙磊

门店分公司和区域信息

Signed-off-by: 孙磊's avatarsunlei <sunlei@romens.cn>
parent aa41e653
......@@ -168,7 +168,8 @@ class BranchController extends BaseController
* @OA\Property(property="RECIVER_CITY",description="城市编号",type="string"),
* @OA\Property(property="RECIVER_REGION",description="区域编号",type="string"),
* @OA\Property(property="ADDRESS",description="详细地址",type="string"),
* @OA\Property(property="PARENT_GUID",description="上级部门编号",type="string"),
* @OA\Property(property="SUPPROVINCE_GUID",description="上级部门分公司",type="string"),
* @OA\Property(property="PARENT_GUID",description="上级部门区域",type="string"),
* @OA\Property(property="LAT",description="门店坐标LAT",type="string"),
* @OA\Property(property="LNG",description="门店坐标LNG",type="string"),
* @OA\Property(property="IS_POINTS_SHOP",description="是否积分门店",type="int"),
......@@ -313,6 +314,106 @@ class BranchController extends BaseController
}
return $info;
}
/**
* @OA\Get(
* path="/backend/web/v1/branch/branches/branch-sup-company",
* tags={"门店&DC"},
* description="获取所有分公司信息",
* summary="获取所有分公司信息(孙磊)",
* @OA\Response(response="200",description="
* GUID:分公司GUID,
* NAME:分公司名称,
* "),
* security={{"Authorization": {}}}
* )
*/
public function actionBranchSupCompany()
{
$model = new $this->modelClass();
$info = $model->getAllSupCompany();
if (!$info) {
throw new BadRequestHttpException('未找到符合的分公司信息');
}
return $info;
}
/**
* @OA\Get(
* path="/backend/web/v1/branch/branches/branch-sup-region",
* tags={"门店&DC"},
* description="获取门店区域信息",
* summary="编辑时获取门店区域信息(孙磊)",
* @OA\Parameter(name="SUPPROVINCE_GUID",in="query",description="所属省级公司GUID",@OA\Schema(type="string")),
* @OA\Response(response="200",description="
* GUID:门店区域GUID,
* NAME:门店区域名称,
* "),
* security={{"Authorization": {}}}
* )
*/
public function actionBranchSupRegion()
{
//权限信息
$rbac = new ShopRbacUser();
$userGuid = Yii::$app->user->identity->GUID;
$userinfo = $rbac->getRbacUserInfo($userGuid);
$auth_role = $userinfo['ROLE_ID'];
$model = new $this->modelClass();
$SUPPROVINCE_GUID = $model->SUPPROVINCE_GUID = Yii::$app->request->get('SUPPROVINCE_GUID');
if ($model->validate()) {
//所有输入数据都有效 all inputs are valid
$info = $model->getBranchRegion($SUPPROVINCE_GUID);
if (!$info) {
throw new BadRequestHttpException('未找到符合的门店区域信息');
}
$info[0]['ROLE_ID'] = $auth_role;
return $info;
} else {
//验证失败:$errors 是一个包含错误信息的数组
Yii::$app->response->statusCode = 422;
return $model->errors;
}
}
/**
* @OA\Get(
* path="/backend/web/v1/branch/branches/sup-company-region",
* tags={"门店&DC"},
* description="获取分公司下区域信息",
* summary="添加时获取分公司下区域信息(孙磊)",
* @OA\Parameter(name="SUPPROVINCE_GUID",in="query",description="所属省级公司GUID",@OA\Schema(type="string")),
* @OA\Response(response="200",description="
* GUID:门店区域GUID,
* NAME:门店区域名称,
* "),
* security={{"Authorization": {}}}
* )
*/
public function actionSupCompanyRegion()
{
//权限信息
$rbac = new ShopRbacUser();
$userGuid = Yii::$app->user->identity->GUID;
$userinfo = $rbac->getRbacUserInfo($userGuid);
$auth_role = $userinfo['ROLE_ID'];
$model = new $this->modelClass();
$SUPPROVINCE_GUID = $model->SUPPROVINCE_GUID = Yii::$app->request->get('SUPPROVINCE_GUID');
if ($model->validate()) {
//所有输入数据都有效 all inputs are valid
$info = $model->getBranchRegion($SUPPROVINCE_GUID,1);
if (!$info) {
throw new BadRequestHttpException('未找到符合的门店区域信息');
}
$info[0]['ROLE_ID'] = $auth_role;
return $info;
} else {
//验证失败:$errors 是一个包含错误信息的数组
Yii::$app->response->statusCode = 422;
return $model->errors;
}
}
/**
* @OA\PUT(
* path="/backend/web/v1/branch/branches/revise-branch",
......@@ -333,7 +434,8 @@ class BranchController extends BaseController
* @OA\Property(property="RECIVER_CITY",description="城市编号",type="string"),
* @OA\Property(property="RECIVER_REGION",description="区域编号",type="string"),
* @OA\Property(property="ADDRESS",description="详细地址",type="string"),
* @OA\Property(property="PARENT_GUID",description="上级部门编号",type="string"),
* @OA\Property(property="SUPPROVINCE_GUID",description="上级部门分公司",type="string"),
* @OA\Property(property="PARENT_GUID",description="上级部门区域",type="string"),
* @OA\Property(property="LAT",description="门店坐标LAT",type="string"),
* @OA\Property(property="LNG",description="门店坐标LNG",type="string"),
* @OA\Property(property="IS_POINTS_SHOP",description="是否积分门店",type="int"),
......
......@@ -371,6 +371,34 @@ class ShopBranch extends BaseModel
return $query;
}
//获取所有分公司信息
public function getAllSupCompany()
{
return $query = static::find()
->select('GUID,NAME')
->where(['BRANCH_TYPE'=>1])
->all();
}
//获取门店区域信息或分公司下区域信息
public function getBranchRegion($SUPPROVINCE_GUID,$flag='')
{
if(empty($flag) && !empty($SUPPROVINCE_GUID)){
return $query = static::find()
->select('GUID,NAME')
->where(['BRANCH_TYPE'=>2])
->andWhere(['PARENT_GUID'=>$SUPPROVINCE_GUID])
->asArray()
->all();
}
if(!empty($flag) && !empty($SUPPROVINCE_GUID)){
return $query = static::find()
->select('GUID,NAME')
->andWhere(['PARENT_GUID'=>$SUPPROVINCE_GUID])
->asArray()
->all();
}
return '';
}
/**
* 查询DC列表
* @params array $params 查询参数数组
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment