|
|
@@ -136,15 +136,15 @@ class CanteenController extends Controller
|
|
|
'weixin' => Helper::getPostString('weixin'),
|
|
|
'memo' => Helper::getPostString('memo'),
|
|
|
];
|
|
|
+ $company_id = Helper::getPostInt('company_id');
|
|
|
|
|
|
$notNullField = ["school_id","name","stall_num","is_direct","username","phone","weixin"];
|
|
|
- $allowEmptyField = ["stall_num","is_direct"];
|
|
|
+ $allowEmptyField = ["stall_num","is_direct",'weixin'];
|
|
|
|
|
|
// 空字段检测
|
|
|
if (!Helper::checkEmptyKey($data, $notNullField, $allowEmptyField)) {
|
|
|
Helper::error('参数错误');
|
|
|
}
|
|
|
-
|
|
|
$name = $data['name'];
|
|
|
// 检测名称重复
|
|
|
$cri = DbCriteria::simpleCompare(['name' => $name])->setSelect('id');
|
|
|
@@ -154,6 +154,9 @@ class CanteenController extends Controller
|
|
|
if ($fid = DB::getScalerWithCriteria(self::$table, $cri)) {
|
|
|
Helper::error('食堂名称已存在 ' . $fid);
|
|
|
}
|
|
|
+
|
|
|
+ $this->dobuleCheck();
|
|
|
+
|
|
|
$data['stall_imgs'] = $data['stall_imgs'] ? implode(',', $data['stall_imgs']) : '';
|
|
|
|
|
|
$trans = \Yii::app()->db->beginTransaction();
|
|
|
@@ -164,7 +167,9 @@ class CanteenController extends Controller
|
|
|
DB::addData(self::$table, $data);
|
|
|
}
|
|
|
Db::deleteByCondition('company_canteen_relation', ['canteen_id' => $id]);
|
|
|
- Db::addData('company_canteen_relation', ['canteen_id' => $id, 'company_id' => $data['school_id'], 'school_id' => $data['school_id']]);
|
|
|
+ if ($company_id) {
|
|
|
+ Db::addData('company_canteen_relation', ['canteen_id' => $id, 'company_id' => $company_id, 'school_id' => $data['school_id']]);
|
|
|
+ }
|
|
|
$trans->commit();
|
|
|
} catch (\Exception $e) {
|
|
|
$trans->rollback();
|