Commit 92c64f4e authored by zhuwei's avatar zhuwei

办公室列表

parent 6d58992b
......@@ -9,6 +9,7 @@ namespace app\index\controller;
use app\index\extend\Basic;
use app\model\AStore;
use app\model\FOffice;
use think\Request;
......@@ -65,23 +66,33 @@ class StoreFee extends Basic
* 办公室列表
* @return \think\Response
*/
public function getSiteList()
public function getOfficeList()
{
$params = $this->params;
/*$params = array(
"id" => 5740
"office_name" => '鳖'
"office_address" => '上海市黄浦区龙华东路800号'
);*/
$field = 'id,name,city,is_del';
$conditions = [];
if ($params['is_del']) {
$params['is_del'] = 0;
if (!empty($params['office_name'])) {
$conditions['office_name'] = ['LIKE', '%'.$params['office_name'].'%'];
}
if (!empty($params['office_address'])) {
$conditions['office_address'] = ['LIKE', '%'.$params['office_address'].'%'];
}
$field = 'id,office_name,office_address,create_time';
$res = $this->f_office->getOffice($field, $conditions);
if(!$res)
return $this->response("200", "成功", []);
$m_store = new AStore();
foreach ($res as $k => $v) {
$res[$k]['store_num'] = $m_store->getOfficeStore($v['id']);//办公室门店数
}
$res = $this->f_office->getOffice($field, $params);
$data['list'] = $res;
return $this->response("200", "成功", $data);
}
......
......@@ -323,4 +323,18 @@ class AStore extends BaseModel
return $data;
}
/**
* 办公室门店数
* @param $office_id
* @return int|string
*/
public function getOfficeStore($office_id) {
$params['office_id'] = $office_id;
$params['status'] = 0;
$store_num = $this
->where($params)
->count();
return $store_num;
}
}
\ No newline at end of file
......@@ -54,12 +54,11 @@ class FOffice extends BaseModel
*/
public function getOffice($field,$params)
{
$params['is_del'] = 0;
$result = $this->db_
->field($field)
//->alias('a')
->where($params)
->select();
//dump($this->db_->getLastSql());
return $result;
}
//
......
......@@ -509,7 +509,8 @@ Route::group('index', [
'yindaoAndroidOffice' => ['index/ShareOfficeRoom/yindaoAndroid', ['method' => 'POST|GET']],
'yindaoIosOffice' => ['index/ShareOfficeRoom/yindaoIos', ['method' => 'POST|GET']],
'addOffice' => ['index/StoreFee/addOffice', ['method' => 'POST|GET']],
'addOffice' => [ 'index/StoreFee/addOffice', [ 'method' => 'POST|GET' ] ],
'getOfficeList' => [ 'index/StoreFee/getOfficeList', [ 'method' => 'POST|GET' ] ],
]);
......
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