Commit 4985c66c authored by 张晓林's avatar 张晓林

Merge branch 'development' of http://gitlab-ebiz.yiyao365.cn/newshop/newshopback into development

parents 8e998340 1cd5eeb3
...@@ -116,7 +116,7 @@ class CompanyController extends BaseController ...@@ -116,7 +116,7 @@ class CompanyController extends BaseController
$model->scenario = 'create';//创建的场景 $model->scenario = 'create';//创建的场景
$other_param = array( $other_param = array(
'GUID'=>Func::create_guid(), 'GUID'=>Func::create_guid(),
'ORG_GUID'=>Yii::$app->user->identity->ORG_GUID, 'ORG_GUID'=>'100',//Yii::$app->user->identity->ORG_GUID,
); );
$model->setAttributes($other_param); $model->setAttributes($other_param);
$model->setAttributes(Yii::$app->request->getBodyparams()); $model->setAttributes(Yii::$app->request->getBodyparams());
...@@ -125,6 +125,8 @@ class CompanyController extends BaseController ...@@ -125,6 +125,8 @@ class CompanyController extends BaseController
throw new HttpException(201,'添加成功'); throw new HttpException(201,'添加成功');
} elseif (!$model->hasErrors()) { } elseif (!$model->hasErrors()) {
throw new HttpException(500,'添加失败'); throw new HttpException(500,'添加失败');
}else{
return $model;
} }
} }
...@@ -167,11 +169,13 @@ class CompanyController extends BaseController ...@@ -167,11 +169,13 @@ class CompanyController extends BaseController
$model->scenario = 'update';//创建的场景 $model->scenario = 'update';//创建的场景
$model->setAttributes(Yii::$app->request->getBodyparams()); $model->setAttributes(Yii::$app->request->getBodyparams());
if ($model->save() === false && !$model->hasErrors()) { if ($model->save()) {
throw new HttpException(500,'修改失败');
}
throw new HttpException(200,'修改成功'); throw new HttpException(200,'修改成功');
} elseif (!$model->hasErrors()) {
throw new HttpException(500,'添加失败');
}else{
return $model;
}
} }
/** /**
......
...@@ -38,10 +38,11 @@ class ShopTransportCompany extends BaseModel ...@@ -38,10 +38,11 @@ class ShopTransportCompany extends BaseModel
*/ */
public function scenarios() public function scenarios()
{ {
return [ $scenarios = [
self::SCENARIO_CREATE => ['GUID', 'ORG_GUID', 'CODE', 'NAME', 'PHONE', 'DESCRIPTION', 'IS_DEFAULT'], self::SCENARIO_CREATE => ['GUID', 'ORG_GUID', 'CODE', 'NAME', 'PHONE', 'DESCRIPTION', 'IS_DEFAULT'],
self::SCENARIO_UPDATE => ['CODE', 'NAME', 'PHONE', 'DESCRIPTION', 'IS_DEFAULT'], self::SCENARIO_UPDATE => ['CODE', 'NAME', 'PHONE', 'DESCRIPTION', 'IS_DEFAULT'],
]; ];
return array_merge (parent::scenarios(),$scenarios);
} }
/** /**
...@@ -50,8 +51,8 @@ class ShopTransportCompany extends BaseModel ...@@ -50,8 +51,8 @@ class ShopTransportCompany extends BaseModel
public function rules() public function rules()
{ {
return [ return [
[['GUID', 'ORG_GUID', 'CODE', 'IS_DEFAULT','NAME'], 'required','message'=>'{attribute}为必填项','on'=>self::SCENARIO_CREATE], [['GUID', 'ORG_GUID', 'CODE', 'IS_DEFAULT','NAME'], 'required','on'=>[self::SCENARIO_CREATE]],
[['CODE', 'IS_DEFAULT','NAME'], 'required','message'=>'{attribute}为必填项','on'=>self::SCENARIO_UPDATE], [['CODE', 'IS_DEFAULT','NAME'], 'required','on'=>[self::SCENARIO_UPDATE]],
[['PHONE'], 'match','pattern' => '/^1\d{10}$/','message'=>'手机号格式不正确'], [['PHONE'], 'match','pattern' => '/^1\d{10}$/','message'=>'手机号格式不正确'],
[['IS_DEFAULT'], 'boolean','message'=>'{attribute}传值错误'], [['IS_DEFAULT'], 'boolean','message'=>'{attribute}传值错误'],
]; ];
......
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