Commit 9ff32c2d authored by hujun's avatar hujun

门店站点id

parent f2d7b7c3
...@@ -11,6 +11,7 @@ namespace app\index\controller; ...@@ -11,6 +11,7 @@ namespace app\index\controller;
use app\index\extend\Basic; use app\index\extend\Basic;
use app\index\validate\StoreValidate; use app\index\validate\StoreValidate;
use app\model\ADistrict;
use app\model\AStore; use app\model\AStore;
class Store extends Basic class Store extends Basic
...@@ -83,16 +84,30 @@ class Store extends Basic ...@@ -83,16 +84,30 @@ class Store extends Basic
} }
$store_validate = new StoreValidate(); $store_validate = new StoreValidate();
$store = new AStore();
$m_district = new ADistrict();
if (empty($this->params['id'])) { if (empty($this->params['id'])) {
if (!$store_validate->scene('add')->check($this->params)) { if (!$store_validate->scene('add')->check($this->params)) {
return $this->response(101, $store_validate->getError()); return $this->response(101, $store_validate->getError());
} }
$this->params['site_id'] = $m_district->getDistrictKeyById('site_id', ['id'=>$this->params['district_id']]);
} else { } else {
if (!$store_validate->scene('edit')->check($this->params)) { if (!$store_validate->scene('edit')->check($this->params)) {
return $this->response(101, $store_validate->getError()); return $this->response(101, $store_validate->getError());
} }
$district_id = $store->getStoreKeyById('district_id', ['id'=>$this->params['id']]);
$old_site_id = $m_district->getDistrictKeyById('site_id', ['id'=>$district_id]);
$new_site_id = $m_district->getDistrictKeyById('site_id', ['id'=>$this->params['district_id']]);
if ($old_site_id != $new_site_id) {
return $this->response(101, '编辑门店部门,导致所属城市不一致');
}
$this->params['site_id'] = $new_site_id;
} }
$store = new AStore();
$this->data = $store->addStoreAgents($this->params, $this->params['agents_id']); $this->data = $store->addStoreAgents($this->params, $this->params['agents_id']);
return $this->response($this->code, $this->msg, $this->data); return $this->response($this->code, $this->msg, $this->data);
......
...@@ -34,15 +34,16 @@ class AStore extends BaseModel ...@@ -34,15 +34,16 @@ class AStore extends BaseModel
$store_data['store_name'] = $data['store_name']; $store_data['store_name'] = $data['store_name'];
$store_data['scale'] = $data['scale']; $store_data['scale'] = $data['scale'];
$store_data['district_id'] = $data['district_id']; $store_data['district_id'] = $data['district_id'];
$store_data['site_id'] = $data['site_id'];
$store_data['code'] = implode('##',$code_arr); $store_data['code'] = implode('##',$code_arr);
if ($data['id'] == '') { if ($data['id'] == '') {
$store_data['create_time'] = date('Y-m-d H:i:s'); $store_data['create_time'] = date('Y-m-d H:i:s');
$this->save($store_data); $this->save($store_data);
$resutlt = $this->id; $result = $this->id;
} else { } else {
$this->save($store_data, ['id'=>$data['id']]); $this->save($store_data, ['id'=>$data['id']]);
$resutlt = $data['id']; $result = $data['id'];
} }
//处理经纪人等级 10业务员 20店长 30总监 40店长和总监 //处理经纪人等级 10业务员 20店长 30总监 40店长和总监
......
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