Commit 3d30843d authored by 郭勇志's avatar 郭勇志

o2o列表接口

parent 1fc56758
......@@ -10,3 +10,4 @@ defined('PAGE_SIZE') or define('PAGE_SIZE',10);//分页,默认每页提供数
defined('USER_ROLE_HEADQUARTERS_ADMIN') or define('USER_ROLE_HEADQUARTERS_ADMIN',1);//总部权限管理员1
defined('USER_ROLE_REGION_ADMIN') or define('USER_ROLE_REGION_ADMIN',2);//分部管理员权限2
defined('USER_ROLE_STORE_ADMIN') or define('USER_ROLE_STORE_ADMIN',3);//分部管理员权限3
defined('O2O_FLAG') or define('O2O_FLAG',2);//o2o类型标志量
......@@ -226,6 +226,16 @@ return [
'POST,OPTIONS initial-price-import'=>'initial-price-import',
],
],
//o2o配送价格
[
'class'=>'yii\rest\UrlRule',
'controller'=>[
'v1/transport/o2o-delivery',
],
'extraPatterns'=>[
'GET,OPTIONS o2o-delivery-list' => 'o2o-delivery-list',
],
],
],
],
]
......
......@@ -4,7 +4,7 @@ namespace backend\controllers\v1\transport;
use backend\controllers\v1\BaseController;
use Yii;
use app\models\v1\rbacuser\ShopRbacUser;
use yii\data\ActiveDataProvider;
class O2oDeliveryController extends BaseController
{
public $modelClass = 'app\models\v1\branch\ShopCityDistributionSetting';
......@@ -34,6 +34,48 @@ class O2oDeliveryController extends BaseController
public function actionO2oDeliveryList()
{
$get = Yii::$app->request->get();
$model = new $this->modelClass;
$model->attributes = $get;
if ($model->validate()) {
$rbacModel = new ShopRbacUser();
$userGuid = Yii::$app->user->identity->GUID;
$userInfo = $rbacModel->getRbacUserInfo($userGuid);
switch ($userInfo['ROLE_ID']) {
case USER_ROLE_HEADQUARTERS_ADMIN:
$branchGuid='';
$parentBranchGuid='';
break;
case USER_ROLE_REGION_ADMIN:
$branchGuid=$userInfo['BRANCH_GUID'];
$parentBranchGuid=$userInfo['BRANCH_GUID'];
break;
case USER_ROLE_STORE_ADMIN:
$branchGuid=$userInfo['BRANCH_GUID'];
$parentBranchGuid='';
break;
}
$query = $model->find()
->alias('scds')
->select('scds.GUID,sb.NAME as BRANCH_NAME,sb.CODE as BRANCH_CODE,scds.REGION_TYPE,scdr.DELIVERY_PRICE,scds.REGION_DISTR_DISTANCE,scds.REGION_DISTR_PRICE,scds.INCREASE_DISTANCE,scds.INCREASE_PRICE')
->leftjoin('shop_branch sb','sb.GUID=scds.BRANCH_GUID')
->leftjoin('shop_city_distribution_region scdr','scdr.CITY_DISTR_GUID=scds.GUID')
->andFilterWhere(['scds.SETTING_TYPE'=>2])//设定为o2o配送
->andFilterWhere(['or',['sb.CODE'=>isset($get['BRANCH_INFO'])?$get['BRANCH_INFO']:''],['like','sb.NAME',isset($get['BRANCH_INFO'])?$get['BRANCH_INFO']:'']])
->andFilterWhere(['sb.GUID'=>$branchGuid])
->orFilterWhere(['sb.PARENTGUID'=>$parentBranchGuid])
->asArray();
return new ActiveDataProvider(
[
'query' => $query,
'pagination' => [
'pageSize'=>PAGE_SIZE,
]
]
);
}else{
Yii::$app->response->statusCode = 422;
return $model->errors;
}
}
}
......@@ -135,17 +135,11 @@ class ShopBranch extends BaseModel
'IS_DELIVERY_CODECHAIN_GOODS', 'IS_SHELVE', 'IS_BRANCH_SELF_MENTION', 'IS_BRANCH_EXPRESS_DELIVERY',
'IS_DELIVERS_GOODS','IS_EXPRESS_DELIVERY','IS_BRANCH_SELF_DELIVERY','IS_HAFL_HOUR_DELIVERY',
'IS_ONE_HOUR_DELIVERY','IS_TWO_HOUR_DELIVERY',
'IS_DAY_DELIVERY'], 'validateExistence','on'=>['import']],
'IS_DAY_DELIVERY'], 'in','range' => [0,1],'on'=>['import'],'message' => '{attribute}只能为0或1'],
[['SERVICE_TYPE_CODE'], 'validateEffective'],//如果影响性能就注释掉
];
}
//验证这几个标志量只能为0或1
public function validateExistence($attribute){
if (!in_array($this->$attribute,['0','1'])) {
$this->addError($attribute, $this->attributeLabels()[$attribute].'只能为0或1.');
}
}
//验证服务类目的有效性
public function validateEffective($attribute){
$importArr = explode(',',$this->$attribute);
......
......@@ -40,6 +40,8 @@ use app\models\v1\branch\ShopCityDistributionRegion;
*/
class ShopCityDistributionSetting extends BaseModel
{
// 输入的门店编码或者门店名称
public $BRANCH_INFO;
/**
* {@inheritdoc}
*/
......@@ -59,6 +61,7 @@ class ShopCityDistributionSetting extends BaseModel
[['STATUS'], 'boolean'],
[['REGION_TYPE','SETTING_TYPE'], 'in', 'range' => [1, 2],'on'=>['insert','update']],
[['BRANCH_GUID'], 'exist', 'skipOnError' => true, 'targetClass' => ShopBranch::className(), 'targetAttribute' => ['BRANCH_GUID' => 'GUID']],
[['BRANCH_INFO'],'match', 'pattern' => '/^[0-9a-zA-Z_\x{4e00}-\x{9fa5}]+$/u','message'=>'只能包含中文汉字,字母,数字','on' => 'search']
];
}
......
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