Commit 5a3e9e3f authored by hujun's avatar hujun

门店店长

parent 750fedc3
...@@ -78,11 +78,6 @@ class Store extends Basic ...@@ -78,11 +78,6 @@ class Store extends Basic
* @throws \think\exception\PDOException3 * @throws \think\exception\PDOException3
*/ */
public function addStore() { public function addStore() {
if (empty($this->params['agents_id'])) {
return $this->response(101, '参数错误,修改失败!');
}
$store_validate = new StoreValidate(); $store_validate = new StoreValidate();
$store = new AStore(); $store = new AStore();
$m_district = new ADistrict(); $m_district = new ADistrict();
......
...@@ -52,7 +52,7 @@ class StoreValidate extends Validate ...@@ -52,7 +52,7 @@ class StoreValidate extends Validate
]; ];
protected $scene = [ protected $scene = [
'add' => ['agents_id','province','city','district','address','longitude','latitude','store_name','scale','district_id'], 'add' => ['province','city','district','address','longitude','latitude','store_name','scale','district_id'],
'edit' => ['id','agents_id','province','city','district','address','longitude','latitude','store_name','scale','district_id'] 'edit' => ['id','agents_id','province','city','district','address','longitude','latitude','store_name','scale','district_id']
]; ];
......
...@@ -23,6 +23,7 @@ class AStore extends BaseModel ...@@ -23,6 +23,7 @@ class AStore extends BaseModel
* @throws \think\exception\PDOException3 * @throws \think\exception\PDOException3
*/ */
public function addStoreAgents($data, $agents_id) { public function addStoreAgents($data, $agents_id) {
$agents_data = [];
$regions = new Regions(); $regions = new Regions();
$code_arr = $regions->getRegionsCodeByName($data['province'], $data['city'], $data['district']); $code_arr = $regions->getRegionsCodeByName($data['province'], $data['city'], $data['district']);
$store_data['province'] = $data['province']; $store_data['province'] = $data['province'];
...@@ -46,14 +47,14 @@ class AStore extends BaseModel ...@@ -46,14 +47,14 @@ class AStore extends BaseModel
$result_id = $data['id']; $result_id = $data['id'];
} }
//处理经纪人等级 10业务员 20店长 30总监 40店长和总监
$agents = new AAgents(); $agents = new AAgents();
$agents_info = $agents->where([ $agents_info = $agents->where([
'store_id'=>$data['id'], 'level'=>['in','20,40'] 'store_id'=>$data['id'], 'level'=>['in','20,40']
])->column('id,level'); ])->column('id,level');
if ($result_id && !empty($agents_id)) {
//处理经纪人等级 10业务员 20店长 30总监 40店长和总监
if ($agents_info) { if ($agents_info) {
$agents_data = [];
foreach ($agents_info as $k=>$v) { foreach ($agents_info as $k=>$v) {
if ($agents_id != $k) { if ($agents_id != $k) {
//40等级和店长降级为业务员 //40等级和店长降级为业务员
...@@ -77,6 +78,22 @@ class AStore extends BaseModel ...@@ -77,6 +78,22 @@ class AStore extends BaseModel
} }
$agents_store['store_id'] = $result_id; $agents_store['store_id'] = $result_id;
$agents->editData($agents_store,$agents_id,'id'); $agents->editData($agents_store,$agents_id,'id');
} else {
foreach ($agents_info as $k=>$v) {
if ($agents_id != $k) {
//40等级和店长降级为业务员
$agents_data[$k]['id'] = $k;
if ($v['level'] == 20) {
$agents_data[$k]['level'] = 10;
} else {
$agents_data[$k]['level'] = 30;
}
$agents_data[$k]['store_id'] = $result_id;
}
}
$agents->saveAll($agents_data);
}
return $result_id; return $result_id;
} }
......
...@@ -257,7 +257,7 @@ define(['doT', 'text!temp/store_template_tpl.html', 'css!style/home.css', 'ckfin ...@@ -257,7 +257,7 @@ define(['doT', 'text!temp/store_template_tpl.html', 'css!style/home.css', 'ckfin
par.store_name = $("input[name =name]").val();//门店名 par.store_name = $("input[name =name]").val();//门店名
par.scale = $("#pid-select option:selected").val();//规模 par.scale = $("#pid-select option:selected").val();//规模
par.district_id= $("#ss-store option:selected").val();//部门id par.district_id= $("#ss-store option:selected").val();//部门id
if(!(par.agents_id && par.province && par.city && par.district && par.address && par.longitude && par.latitude && par.store_name && par.scale && par.district_id)){ if(!(par.province && par.city && par.district && par.address && par.longitude && par.latitude && par.store_name && par.scale && par.district_id)){
alert('请将内容填写完整'); alert('请将内容填写完整');
return; return;
} }
......
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