Commit f93a0df4 authored by clone's avatar clone

成交列表

parent 4b5001f1
<?php
namespace app\api_broker\controller;
use app\api_broker\extend\Basic;
use app\api_broker\service\BargainService;
use think\Request;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/8/23
* Time : 14:39
* Intro:
*/
class Bargain extends Basic
{
private $service_;
public function __construct($request = null)
{
parent::__construct($request);
$this->service_ = new BargainService();
}
public function bargainList()
{
$params = $this->params;
/* $params = array(
"submit_agent_id" => 1,
"status" => 0,//0全部 1未结单 2已结单 3 撤销审核 4已撤销
"is_my_correlation" => 1, //是否与我相关 0全部 1与我相关
"keyword" => "17717536291",
"page_no" => 1,
"page_size" => 15
);*/
$checkResult = $this->validate($params, "BargainValidate.bargainList");
if (true !== $checkResult) {
return $this->response("300", $checkResult);
}
$pageNo = empty($params["page_no"]) ? 1 : $params["page_no"];
$pageSize = empty($params["page_size"]) ? 15 : $params["page_size"];
$submit_agent_id = $params["page_size"];
$status = $params["status"];
$is_my_correlation = $params["is_my_correlation"];
$keyword = $params["keyword"];
$result = $this->service_->getBargainList($pageNo, $pageSize, $submit_agent_id, $status, $is_my_correlation,$keyword);
return $this->response("200", "success", $result);
}
}
\ No newline at end of file
<?php
namespace app\api_broker\service;
use app\model\OBargainModel;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/8/23
* Time : 14:45
* Intro:
*/
class BargainService
{
/**
* 获取成交报告列表
* @param $pageNo
* @param $pageSize
* @param $submit_agent_id
* @param $status
* @param $is_my_correlation
* @param $keyword
* @return array|false|\PDOStatement|string|\think\Collection
*/
public function getBargainList($pageNo, $pageSize, $submit_agent_id, $status, $is_my_correlation, $keyword)
{
$condition = [];
if ($is_my_correlation == 1) {
$aService = new VerifyService();
$ids = $aService->getAgentsByAgentId($submit_agent_id);
$condition["ids"] = $ids;
} else {
$condition["father_id"] = 0;
}
switch ($status) {
case 1:
$condition["account_statement"] = 0;
break;
case 2:
$condition["account_statement"] = 1;
break;
case 3:
$condition["status"] = 20;
break;
case 4:
$condition["status"] = 21;
break;
default:
}
if (!empty($keyword)) {
$condition["keyword"] = $keyword;
}
$bargainModel = new OBargainModel();
$filed = "a.id,a.father_id,a.house_number,a.price,a.commission,a.agent_id,a.create_time,b.user_phone,b.user_name,b.user_id,c.id as order_id,
d.id as house_id,d.internal_title,d.internal_address";
$result = $bargainModel->selectBargainList($filed, $condition, $pageNo, $pageSize);
return $this->convert($is_my_correlation, $result);
}
private function convert($is_my_correlation, $result)
{
$sortResult = [];
if ($is_my_correlation == 1) {
$list = [];
foreach ($result as $k => $v) {
$father_id = $v["father_id"];
if ($father_id > 0 && in_array($father_id, $list)) {
unset($result[$k]);
} else {
$result[$k]["create_time"] = date("Y-m-d", strtotime($v["create_time"]));
$result[$k]["id"] = $v["father_id"] == 0 ? $v["id"] : $v["father_id"];
array_push($list, $father_id);
}
}
foreach ($result as $k => $v) {
$sortResult[] = $v;
}
} else {
$sortResult = $result;
}
return $sortResult;
}
}
\ No newline at end of file
<?php
namespace app\api_broker\validate;
use think\Validate;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/8/23
* Time : 14:51
* Intro:
*/
class BargainValidate extends Validate
{
protected $rule = [
'submit_agent_id' => 'require|number',
'status' => 'require|number|in:0,1,2,3',
'is_my_correlation' => 'require|number|in:0,1',
];
protected $message = [
'submit_agent_id.require' => '经纪人为必填字段',
'submit_agent_id.number' => '经纪人id只能为数字',
'status.require' => '状态参数不能为空',
'status.number' => '状态参数只能为数字',
'status.in' => '状态错误',
'is_my_correlation.require' => '与我相关不能为空',
'is_my_correlation.number' => '与我相关只能是数字',
'is_my_correlation.in' => '与我相关错误',
];
protected $scene = [
'bargainList' => [ 'submit_agent_id', 'status', 'is_my_correlation' ],
];
}
\ No newline at end of file
......@@ -244,6 +244,15 @@ class OBargainModel extends Model
if (isset($params["ids"])) {
$where_["a.agent_id"] = array( "in", $params["ids"] );
}
if (isset($params["account_statement"])) {
$where_["a.account_statement"] = $params["account_statement"];
}
if (isset($params["father_id"])) {
$where_["a.father_id"] = $params["father_id"];
}
if (isset($params["keyword"])) {
$where_["b.user_phone|b.user_name|d.internal_address"] = array( "like", "%" . $params["keyword"] . "%" );
}
......@@ -261,7 +270,7 @@ class OBargainModel extends Model
->limit($pageSize)
->page($pageNo)
->select();
// echo $this->db_->getLastSql();
//echo $this->db_->getLastSql();
return $result;
}
......@@ -449,9 +458,9 @@ class OBargainModel extends Model
//记录第几级审核-与 OFinancialAudit 表一致
$update_data['audit_level'] = $data['audit_level'];
$where_bargain['id'] = $bargain_data['id'];
$where_bargain['status'] = ['<>', 30];
$where_bargain[] = ['EXP', 'id='.$bargain_data['id'] .' or father_id='.$bargain_data['id'] ];
$where_bargain['id'] = $bargain_data['id'];
$where_bargain['status'] = [ '<>', 30 ];
$where_bargain[] = [ 'EXP', 'id=' . $bargain_data['id'] . ' or father_id=' . $bargain_data['id'] ];
$this->where($where_bargain)->update($update_data);
$this->commit();
......@@ -1235,8 +1244,8 @@ class OBargainModel extends Model
->order("a.id asc")
->find();
$result['scale'] = empty($result['new_scale']) ? $result['scale'] : $result['new_scale'];
$result['scale_fee'] = empty($result['should_commission']) ? $result['scale_fee'] : $result['should_commission'];
$result['scale'] = empty($result['new_scale']) ? $result['scale'] : $result['new_scale'];
$result['scale_fee'] = empty($result['should_commission']) ? $result['scale_fee'] : $result['should_commission'];
$m_agent = new AAgents();
$filed_agent = 'a.id,a.name,a.phone,b.store_name,c.district_name,a.store_id,a.district_id';
$agent_info = $m_agent->getAgentsInfoByAgentId($filed_agent, [ 'agent_id' => $result['agent_id'] ]);
......
......@@ -121,13 +121,12 @@ class OFinancialAudit extends BaseModel
if (isset($params["order_id"])) {
$where_["order_id"] = $params["order_id"];
}
$where_["is_del"] = 0;
$where_["status"] = 0;
$data = $this
$data = $this
->field($filed)
->where($where_)
->select();
return $data;
}
}
\ No newline at end of file
......@@ -569,6 +569,10 @@ Route::group('broker', [
'saveSiteCity' => [ 'api_broker/Location/saveSiteCity', [ 'method' => 'POST|GET' ] ], //保存默认城市选择
'bargain' => [ 'api_broker/Bargain/bargainList', [ 'method' => 'POST|GET' ] ],
]);
//Route::miss('api/index/miss');//处理错误的url
\ No newline at end of file
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