Commit 1fc56758 authored by 姚书霞's avatar 姚书霞 🐘

DC仓 and 电子围栏场景

parent 35a6dc53
...@@ -47,6 +47,8 @@ return [ ...@@ -47,6 +47,8 @@ return [
'DELETE,OPTIONS del-branch' => 'del-branch', 'DELETE,OPTIONS del-branch' => 'del-branch',
'POST,OPTIONS branch-img-upload' => 'branch-img-upload', 'POST,OPTIONS branch-img-upload' => 'branch-img-upload',
'GET,OPTIONS export-branch' => 'export-branch', 'GET,OPTIONS export-branch' => 'export-branch',
'GET,OPTIONS dc-branch-list' => 'dc-branch-list',
'GET,OPTIONS dc-branch-export' => 'dc-branch-export',
], ],
], ],
//门店评分 //门店评分
......
...@@ -14,6 +14,8 @@ use yii\web\BadRequestHttpException; ...@@ -14,6 +14,8 @@ use yii\web\BadRequestHttpException;
use backend\helpers\Func; use backend\helpers\Func;
use yii\web\ServerErrorHttpException; use yii\web\ServerErrorHttpException;
use yidas\phpSpreadsheet\Helper; use yidas\phpSpreadsheet\Helper;
use yii\data\ActiveDataProvider;
class BranchController extends BaseController class BranchController extends BaseController
{ {
...@@ -769,4 +771,102 @@ class BranchController extends BaseController ...@@ -769,4 +771,102 @@ class BranchController extends BaseController
} }
} }
/**
* @OA\Get(
* path="/backend/web/v1/branch/branches/dc-branch-list",
* tags={"门店&DC"},
* description="DC仓列表",
* summary="DC仓列表(姚书侠)",
* @OA\Parameter(in = "query",name = "code",description = "门店编码",required = false,@OA\Schema(type="string")),
* @OA\Parameter(in = "query",name = "dcType",description = "DC仓类型 1分公司2区域",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 = "page",description = "分页页码",required = false,@OA\Schema(type="string")),
* @OA\Parameter(in = "query",name = "pageSize",description = "分页大小",required = false,@OA\Schema(type="string")),
* @OA\Response(response="200",description="
* GUID:门店GUID,
* CODE:门店CODE,
* PROVINCE:省名称,
* CITY:市名称,
* REGION:区名称,
* NAME:门店名称,
* PHONE:门店联系电话,
* CONTACT_NAME:门店联系人姓名,
* ADDRESS:详细地址
* LAT:经纬度
* LNG:经纬度
* "),
* security={{"Authorization": {}}}
* )
*/
public function actionDcBranchList()
{
$params = Yii::$app->request->getQueryParams();
$model = new $this->modelClass();
$query = $model->DcBranchList($params);
$result = new ActiveDataProvider(
[
'query' => $query,
'pagination' => [
'pageSize'=>$params['pageSize']??20,
]
]
);
return $result;
}
/**
* @OA\Get(
* path="/backend/web/v1/branch/branches/dc-branch-export",
* tags={"门店&DC"},
* description="DC仓列表导出",
* summary="DC仓列表导出(姚书侠)",
* @OA\Parameter(in = "query",name = "code",description = "门店编码",required = false,@OA\Schema(type="string")),
* @OA\Parameter(in = "query",name = "dcType",description = "DC仓类型 1分公司2区域",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\Response(response="200",description="
* GUID:门店GUID,
* CODE:门店CODE,
* PROVINCE:省名称,
* CITY:市名称,
* REGION:区名称,
* NAME:门店名称,
* PHONE:门店联系电话,
* CONTACT_NAME:门店联系人姓名,
* ADDRESS:详细地址
* LAT:经纬度
* LNG:经纬度
* "),
* security={{"Authorization": {}}}
* )
*/
public function actionDcBranchExport()
{
$params = Yii::$app->request->getQueryParams();
$model = new $this->modelClass();
$query = $model->DcBranchList($params);
$result = $query->all();
$export_result = [];
foreach($result as $key=>&$value){
$export = array(
$value['NAME'],
$value['CODE'],
$value['PHONE'],
$value['ADDRESS'],
$value['LAT'],
$value['LNG'],
);
array_push($export_result,$export);
}
unset($result);
Helper::newSpreadsheet()
->addRow(['门店名称','门店编号','门店电话','联系人姓名','门店地址','LAT','LNG'])
->addRows($export_result)
->output("DC仓列表","Csv");
}
} }
...@@ -232,9 +232,11 @@ class CityDistributionSettingController extends BaseController ...@@ -232,9 +232,11 @@ class CityDistributionSettingController extends BaseController
$region = Yii::$app->getRequest()->post('REGION'); $region = Yii::$app->getRequest()->post('REGION');
if(!empty($guid)){ if(!empty($guid)){
$model = $this->modelClass::findOne($guid); $model = $this->modelClass::findOne($guid);
$model->scenario = 'update';//创建的场景
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){
...@@ -242,14 +244,15 @@ class CityDistributionSettingController extends BaseController ...@@ -242,14 +244,15 @@ class CityDistributionSettingController extends BaseController
}else{ }else{
$model = new $this->modelClass(); $model = new $this->modelClass();
} }
$model->scenario = 'insert';//创建的场景
$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->setAttributes($other_param,false); $model->setAttributes($other_param);
} }
$region_model = new ShopCityDistributionRegion(); $region_model = new ShopCityDistributionRegion();
$model->setAttributes(Yii::$app->getRequest()->post());
//开启事务 //开启事务
$trans = $model->getDb()->beginTransaction(); $trans = $model->getDb()->beginTransaction();
......
...@@ -335,4 +335,38 @@ class ShopBranch extends BaseModel ...@@ -335,4 +335,38 @@ class ShopBranch extends BaseModel
return $query; return $query;
} }
/**
* 查询门店列表
* @params array $params 查询参数数组
* @return array|null 返回查询结果
*/
public function DcBranchList($params)
{
//根据条件查询门店
$branch_query = ShopBranch::find()->alias('sb')
->select("vwb.PROVINCE,vwb.CITY,vwb.REGION,sb.NAME,sb.PHONE,sb.GUID,sb.LAT,sb.LNG,sb.CODE,sb.ADDRESS")
->leftJoin('VW_BRANCH_ADDRESS vwb', 'vwb.GUID=sb.GUID')
->asArray();
//门店名称或编码
if (isset($params['code'])) {
$branch_query->andfilterWhere(['or', ['=','sb.CODE', $params['code']],['like', 'sb.NAME', $params['code']]]);
}
//省市区
if (isset($params['province'])) {
$branch_query->andfilterWhere(['sb.RECIVER_PROVINCE'=>$params['province']]);
}
if (isset($params['city'])) {
$branch_query->andfilterWhere(['sb.RECIVER_CITY'=>$params['city']]);
}
if (isset($params['region'])) {
$branch_query->andfilterWhere(['sb.RECIVER_REGION'=>$params['region']]);
}
//DC类型
if (isset($params['dcType'])) {
$branch_query->andfilterWhere(['sb.BRANCH_TYPE'=>$params['dcType']]);
}else{
$branch_query->andfilterWhere(['in','BRANCH_TYPE',[0,1,2]]);
}
return $branch_query;
}
} }
...@@ -54,10 +54,10 @@ class ShopCityDistributionSetting extends BaseModel ...@@ -54,10 +54,10 @@ class ShopCityDistributionSetting extends BaseModel
public function rules() public function rules()
{ {
return [ return [
[['ORG_GUID','GUID','BRANCH_GUID','REGION_TYPE','SETTING_TYPE',], 'required'], [['ORG_GUID','GUID','BRANCH_GUID','REGION_TYPE','SETTING_TYPE'], 'required','on'=>['insert','update']],
[['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'],
[['REGION_TYPE','SETTING_TYPE'], 'in', 'range' => [1, 2]], [['REGION_TYPE','SETTING_TYPE'], 'in', 'range' => [1, 2],'on'=>['insert','update']],
[['BRANCH_GUID'], 'exist', 'skipOnError' => true, 'targetClass' => ShopBranch::className(), 'targetAttribute' => ['BRANCH_GUID' => 'GUID']], [['BRANCH_GUID'], 'exist', 'skipOnError' => true, 'targetClass' => ShopBranch::className(), 'targetAttribute' => ['BRANCH_GUID' => 'GUID']],
]; ];
} }
......
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