Commit 83cfcd8c authored by 姚书霞's avatar 姚书霞 🐘

电子围栏列表

parent 73c27a76
...@@ -66,7 +66,7 @@ return [ ...@@ -66,7 +66,7 @@ return [
'POST,OPTIONS login'=>'login', 'POST,OPTIONS login'=>'login',
], ],
], ],
//用户等级 //用户
[ [
'class'=>'yii\rest\UrlRule', 'class'=>'yii\rest\UrlRule',
'controller'=>[ 'controller'=>[
...@@ -125,14 +125,18 @@ return [ ...@@ -125,14 +125,18 @@ return [
'DELETE,OPTIONS del-branch-service' => 'del-branch-service', 'DELETE,OPTIONS del-branch-service' => 'del-branch-service',
], ],
], ],
// //门店电子围栏
[ [
'class'=>'yii\rest\UrlRule', 'class'=>'yii\rest\UrlRule',
'controller'=>[ 'controller'=>[
'v1/branch/shop-city-distribution-setting', 'v1/branch/city-distribution-setting',
], ],
'extraPatterns'=>[ 'extraPatterns'=>[
'GET,OPTIONS city-distribution-setting-list' => 'city-distribution-setting-list',
'GET,OPTIONS city-distribution-setting-detail' => 'city-distribution-setting-detail',
'PUT,OPTIONS membergrade-revise' => 'membergrade-revise',
'POST,OPTIONS membergrade-add' => 'membergrade-add',
'DELETE,OPTIONS membergrade-delete' => 'membergrade-delete',
], ],
], ],
//用户列表 //用户列表
......
<?php
namespace backend\controllers\v1\branch;
use Yii;
use backend\controllers\v1\BaseController;
use backend\helpers\Func;
use yii\web\BadRequestHttpException;
use yii\web\ServerErrorHttpException;
class CityDistributionSettingController extends BaseController
{
public $modelClass='app\models\v1\branch\ShopCityDistributionSetting';
/**
* @OA\Get(
* path="/backend/web/v1/branch/city-distribution-settings/city-distribution-setting-list",
* tags={"门店&DC"},
* summary="电子围栏列表(姚书侠)",
* description="电子围栏列表接口",
* @OA\Parameter(in = "query",name = "code",description = "门店编码",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 = "b2c_issetting",description = "是否设置B2C(1是 0否)",required = false,@OA\Schema(type="string")),
* @OA\Parameter(in = "query",name = "o2o_issetting",description = "是否设置020(1是 0否)",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:门店联系电话,
* ADDRESS:门店地址
* B2C_ISSETTING:是否设置B2C
* 020_ISSETTING:是否设置020
* "),
* security={{"Authorization": {}}}
* )
*/
//重写index
public function actionCityDistributionSettingList()
{
$model = new $this->modelClass();
$result = $model->getList();
return $result;
}
/**
* @OA\Get(
* path="/backend/web/v1/branch/city-distribution-settings/city-distribution-setting-detail",
* tags={"门店&DC"},
* summary="电子围栏详情(姚书侠)",
* description="电子围栏详情接口",
* @OA\Parameter(name="guid",in="query",required=true,description="门店GUID",@OA\Schema(type="string")),
* @OA\Response(response = 200,description = "success"),
* security={{"Authorization": {}}}
* )
*/
//编辑用
public function actionCityDistributionSettingDetail()
{
$branchguid = Yii::$app->getRequest()->get('guid');
$model = new $this->modelClass();
$result = $model->getDetail($branchguid);
return $result;
}
}
\ No newline at end of file
<?php
namespace app\models\v1\branch;
use Yii;
use app\models\v1\BaseModel;
use app\models\v1\branch\ShopBranch;
use yii\data\ActiveDataProvider;
/**
* This is the model class for table "shop_city_distribution_setting".
*
* @property string $GUID 电子围栏设置GUID
* @property string $ORG_GUID 组织机构号
* @property string $BRANCH_GUID 门店GUID
* @property int $IS_OWN_DISTR 是否商家自送,1是,0否 暂不用
* @property int $IS_OTHER_DISTR 是否第三方配送,1是,0否 暂不用
* @property string $WORK_TYPE 第三方配送业务类型,暂不用
* @property int $IS_DADA_DISTR 是否开启达达配送,1是,0否 暂不用
* @property string $REGION_TYPE 配送区域类型
* @property string $SIMPLE_DISTR_NOTES 简易版配送范围介绍,暂不用
* @property string $SIMPLE_DISTR_PIC 简易版配送范围图片,暂不用
* @property string $SIMPLE_DISTR_QS_PRICE 简易版配送金额,暂不用
* @property string $SIMPLE_DISTR_PS_PRICE 简易版配送费,暂不用
* @property string $REGION_DISTR_DISTANCE 不同距离不同配送费**公里内
* @property string $REGION_DISTR_PRICE 不同距离不同配送费*公里内*元
* @property string $INCREASE_DISTANCE 不同距离不同配送费增加*公里
* @property string $INCREASE_PRICE 不同距离不同配送费增加*公里*元
* @property string $LAT 门店LAT
* @property string $LNG 门店LNG
* @property string $ADDRESS 门店地址,暂不用
* @property int $IS_TIMING 是否开启定时送功能 1:开启,0不开启 暂不用
* @property int $TIME_SUBDIVISION 时段细分1:天 2:上午或晚上 3:小时 4:半小时,暂不用
* @property string $BOOKING_ORDER 预约下单存入JSON,暂不用
* @property string $MAX_BOOKING 最大预约,暂不用
* @property int $STATUS 是否开启同城配送,1:是
* @property int $SETTING_TYPE 电子围栏类型:1:B2C范围,2:O2O范围
*
* @property CityDistributionRegion[] $cityDistributionRegions
* @property ShopBranch $bRANCHGU
*/
class ShopCityDistributionSetting extends BaseModel
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'shop_city_distribution_setting';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['GUID'], 'required'],
[['IS_OWN_DISTR', 'IS_OTHER_DISTR', 'IS_DADA_DISTR', 'IS_TIMING', 'TIME_SUBDIVISION', 'STATUS', 'SETTING_TYPE'], 'integer'],
[['SIMPLE_DISTR_QS_PRICE', 'SIMPLE_DISTR_PS_PRICE', 'REGION_DISTR_DISTANCE', 'REGION_DISTR_PRICE', 'INCREASE_DISTANCE', 'INCREASE_PRICE'], 'number'],
[['GUID', 'ORG_GUID', 'BRANCH_GUID', 'WORK_TYPE', 'REGION_TYPE', 'ADDRESS', 'BOOKING_ORDER', 'MAX_BOOKING'], 'string', 'max' => 50],
[['SIMPLE_DISTR_NOTES', 'SIMPLE_DISTR_PIC'], 'string', 'max' => 200],
[['LAT', 'LNG'], 'string', 'max' => 20],
[['GUID'], 'unique'],
[['BRANCH_GUID'], 'exist', 'skipOnError' => true, 'targetClass' => ShopBranch::className(), 'targetAttribute' => ['BRANCH_GUID' => 'GUID']],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'GUID' => 'Guid',
'ORG_GUID' => 'Org Guid',
'BRANCH_GUID' => 'Branch Guid',
'IS_OWN_DISTR' => 'Is Own Distr',
'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_QS_PRICE' => 'Simple Distr Qs Price',
'SIMPLE_DISTR_PS_PRICE' => 'Simple Distr Ps Price',
'REGION_DISTR_DISTANCE' => 'Region Distr Distance',
'REGION_DISTR_PRICE' => 'Region Distr Price',
'INCREASE_DISTANCE' => 'Increase Distance',
'INCREASE_PRICE' => 'Increase Price',
'LAT' => 'Lat',
'LNG' => 'Lng',
'ADDRESS' => 'Address',
'IS_TIMING' => 'Is Timing',
'TIME_SUBDIVISION' => 'Time Subdivision',
'BOOKING_ORDER' => 'Booking Order',
'MAX_BOOKING' => 'Max Booking',
'STATUS' => 'Status',
'SETTING_TYPE' => 'Setting Type',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getCityDistributionRegions()
{
return $this->hasMany(CityDistributionRegion::className(), ['CITY_DISTR_GUID' => 'GUID']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getShopBranch()
{
return $this->hasOne(ShopBranch::className(), ['GUID' => 'BRANCH_GUID']);
}
/**
* 获取电子围栏列表(就是门店列表,连电子围栏表)
*/
public function getList()
{
$params = Yii::$app->getRequest()->get();
//根据条件查询门店
$branch_query = ShopBranch::find()->alias('sb')
->select("vwb.PROVINCE,vwb.CITY,vwb.REGION,sb.NAME,sb.PHONE,sb.GUID,sb.CODE,sb.ADDRESS,group_concat(cds.SETTING_TYPE) SETTING_TYPES ")
->leftJoin('shop_city_distribution_setting as cds',"cds.BRANCH_GUID=sb.GUID")
->leftJoin('VW_BRANCH_ADDRESS vwb', 'vwb.GUID=sb.GUID')
->groupBy('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']]);
}
//是否o2o、b2c
if (isset($params['b2c_issetting'])) {
if($params['b2c_issetting']=='1'){
$setting_query = $this::find()->where("SETTING_TYPE='1' AND BRANCH_GUID = sb.GUID");
$branch_query->andfilterWhere(['exists',$setting_query]);
}else if($params['b2c_issetting']=='0'){
$setting_query = $this::find()->where("SETTING_TYPE='1' AND BRANCH_GUID = sb.GUID");
$branch_query->andfilterWhere(['not exists',$setting_query]);
}
}
if (isset($params['o2o_issetting'])) {
if($params['o2o_issetting']=='1'){
$setting_query = $this::find()->where("SETTING_TYPE='2' AND BRANCH_GUID = sb.GUID");
$branch_query->andfilterWhere(['exists',$setting_query]);
}else if($params['o2o_issetting']=='0'){
$setting_query = $this::find()->where("SETTING_TYPE='2' AND BRANCH_GUID = sb.GUID");
$branch_query->andfilterWhere(['not exists',$setting_query]);
}
}
$result = new ActiveDataProvider(
[
'query' => $branch_query,
'pagination' => [
'pageSize'=>$requestParams['pageSize']??20,
]
]
);
//处理数据
$branch_list = $result->getModels();
foreach($branch_list as $key=>&$value){
if(strstr($value['SETTING_TYPES'],'1')){
$value['B2C_ISSETTING']='是';
}else{
$value['B2C_ISSETTING']='否';
}
if(strstr($value['SETTING_TYPES'],'2')){
$value['020_ISSETTING']='是';
}else{
$value['020_ISSETTING']='否';
}
unset($value['SETTING_TYPES']);
}
$result->setModels($branch_list);
return $result;
}
/**
* 获取电子围栏详情
*/
public function getDetail($branchguid)
{
$a = ShopBranch::findOne($branchguid)
->select("GUID,NAME");
print_r($a);die;
}
}
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