Commit 9ef8287f authored by zhuwei's avatar zhuwei

办公室详情

parent c1dc4224
......@@ -51,9 +51,9 @@ class StoreFee extends Basic
$data["rent"] = $params['rent'];
$data["operator_id"] = $this->userId;
$res = $this->f_office->saveOffice($data);//int(1)
$result = $this->f_office->saveOffice($data);//int(1)
if ($res) {
if ($result) {
return $this->response("200", "成功");
} else {
return $this->response("101", "失败");
......@@ -73,7 +73,8 @@ class StoreFee extends Basic
"office_name" => '鳖'
"office_address" => '上海市黄浦区龙华东路800号'
);*/
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 10 : $this->params['pageSize'];
$conditions = [];
if (!empty($params['office_name'])) {
......@@ -82,16 +83,45 @@ class StoreFee extends Basic
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)
$field = 'id,rent,office_name,office_address,create_time';
$result = $this->f_office->getOffice($field, $conditions,$pageNo, $pageSize);
if(!$result)
return $this->response("200", "成功", []);
$m_store = new AStore();
foreach ($res as $k => $v) {
$res[$k]['store_num'] = $m_store->getOfficeStore($v['id']);//办公室门店数
foreach ($result as $k => $v) {
$result[$k]['store_num'] = $m_store->getOfficeStore($v['id']);//办公室门店数
}
$result_total = $this->f_office->getOfficeTotal($field, $conditions);
$data['list'] = $result;
$data['total'] = $result_total;
return $this->response("200", "成功", $data);
}
/**
* 办公室详情
* @return \think\Response
*/
public function getOfficeInfo()
{
$params = $this->params;
// $params = array(
// "id" => '1',//id
// );
$checkResult = $this->validate($params, "StoreFeeValidate.getOfficeInfo");
if (true !== $checkResult) {
return $this->response("101", $checkResult);
}
$conditions = [];
$field = 'id,site_id,office_name,office_address';
$result = $this->f_office->findByOne($field, $conditions);
if (!$result) {
return $this->response("101", '此办公室不存在');
}
$data['list'] = $res;
$data['list'] = $result;
return $this->response("200", "成功", $data);
}
......
......@@ -11,6 +11,10 @@ class StoreFeeValidate extends Validate {
'office_name' => 'require',
'office_address' => 'require',
'rent' => 'require|number|gt:0',
'id' => 'require|number|gt:0',
];
protected $message = [
......@@ -20,10 +24,15 @@ class StoreFeeValidate extends Validate {
'rent.require' => '租金每月不能为空',
'rent.number' => '租金每月只能为数字',
'rent.gt' => '租金每月必须大于0',
'id.require' => 'id为必填字段',
'id.number' => 'id只能为数字',
'id.gt' => 'id必须大于0',
];
protected $scene = [
'addOffice' => [ 'site_id', 'office_name', 'office_address', 'rent' ],
'getOfficeInfo' => [ 'id'],
];
}
\ No newline at end of file
......@@ -37,6 +37,7 @@ class FOffice extends BaseModel
* @return array|false|\PDOStatement|string|Model
*/
public function findByOne($field,$params) {
$params["is_del"] = 0;
$result = $this->db_
->field($field)
->where($params)
......@@ -52,15 +53,27 @@ class FOffice extends BaseModel
* @param $params
* @return false|\PDOStatement|string|\think\Collection
*/
public function getOffice($field,$params)
public function getOffice($field,$params,$pageNo, $pageSize)
{
$params['is_del'] = 0;
$result = $this->db_
->field($field)
->where($params)
->limit($pageSize)
->page($pageNo)
->select();
return $result;
}
public function getOfficeTotal($field,$params)
{
$params['is_del'] = 0;
$result = $this->db_
->field($field)
->where($params)
->count();
return $result;
}
//
// /**
// * 更新数据
......
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