Commit 634fb25d authored by zw's avatar zw

订单搜索

parent bebc797d
......@@ -74,12 +74,12 @@ class OrderLog extends Basic
{
$params = $this->params;
if (!isset($params["agent_id"]) || !isset($params["report_id"]) || !isset($params["order_id"]) || !isset($params["order_no"])
/* if (!isset($params["agent_id"]) || !isset($params["report_id"]) || !isset($params["order_id"]) || !isset($params["order_no"])
|| !isset($params["collecting_bill"]) || !isset($params["collecting_bill"][0]["type"]) || !isset($params["house_number"])
|| !isset($params["industry_type"])) {
return $this->response("101", "请求参数错误");
}
/* $params = array(
}*/
$params = array(
"agent_id" => 1,//收款经纪人id
"report_id" => 111,//报备id
"order_id" => 2, //关联order表id
......@@ -94,7 +94,7 @@ class OrderLog extends Basic
"industry_type" => "asdasdasd",
"remark" => "没什么备注",
"transfer_img" => "12312312312"
);*/
);
$remark = isset($params["remark"]) ? $params["remark"] : "";
$transfer_img = isset($params["transfer_img"]) ? $params["transfer_img"] : "";
......
<?php
namespace app\api_broker\controller;
use app\api_broker\extend\Basic;
use app\api_broker\service\StatementService;
use think\Exception;
use think\Request;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/3/8
* Time : 上午11:22
* Intro:
*/
class Statement extends Basic
{
private $service_;
public function __construct(Request $request = null)
{
parent::__construct($request);
$this->service_ = new StatementService();
}
public function dayStatement()
{
$params = $this->params;
$params = array(
"agent_id" => 1,
//"type" => 1, // 1.日报 2.周报
"time_start" => date("Y-m-d", time()),
"time_end" => date("Y-m-d", time()) . " 23:59:59",
);
if (!isset($params["agent_id"]) || !isset($params["type"])) {
return $this->response("101", "请求参数错误");
}
try {
$result = $this->service_->selectStatementByAgentId($params["agent_id"], $params["time_start"], $params["time_end"]);
if (count($result) > 0) {
return $this->response("200", "request success", $result);
} else {
return $this->response("200", "request is null");
}
} catch (Exception $exception) {
return $this->response("101", "request is error,msg:" . $exception);
}
}
}
\ No newline at end of file
......@@ -63,7 +63,7 @@ class OrderLogService
if (!empty($bill_arr)) {
return $this->payLogModel->addPayLog($bill_arr);
}
return 0;
return $father_id;
}
private function collectingBillBin($father_id,$collecting_arr, $agent_id, $report_id, $order_id, $order_no, $house_number,
......
<?php
namespace app\api_broker\service;
use app\model\AAgents;
use app\model\FollowUpLogModel;
use app\model\GHouses;
use app\model\Users;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/3/8
* Time : 上午11:33
* Intro:
*/
class StatementService {
private $agentModel;
private $houseModel;
private $userModel;
private $followUpModel;
function __construct()
{
$this->agentModel = new AAgents();
$this->houseModel = new GHouses();
$this->userModel = new Users();
$this->followUpModel = new FollowUpLogModel();
}
/**
* @param $agent_id
* @param $time_start
* @param $time_end
* @return array|null
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function selectStatementByAgentId($agent_id,$time_start,$time_end){
$field = "id,store_id,district_id,level,name,phone,sex,status";
$agent_result = $this->agentModel->getAgentById($field,$agent_id);
if(count($agent_result) <= 0){
return null;
}
$user_type = 0; //经纪人权限,0经纪人 1店长 2总监
if($agent_result[0]["level"] == 20){
$user_type = 1;
}elseif ($agent_result[0]["level"] == 30 || $agent_result[0]["level"] == 40 ){
$user_type = 2;
}
$store_id = $agent_result[0]["store_id"];
$district_id = $agent_result[0]["district_id"];
$conditions["agent_id"] = $agent_id;
$conditions['create_time'] = array( 'between', array( $time_start, $time_end ) );
return $this->selectStatement($conditions,$user_type,$store_id,$district_id);
}
private function selectStatement($conditions,$user_type,$store_id,$district_id){
$result = $params = [];
switch ($user_type){
case 0:
//todo
break;
case 1:
//todo 统计门店下的所有经纪人
$params["store_id"] = $store_id;
$params["status"] = 0; //只查询正常状态的经纪人
break;
case 2:
$params["district_id"] = $district_id;
$params["status"] = 0; //只查询正常状态的经纪人
break;
}
if(!empty($params)){
$agentsArr = $this->agentModel->getAgentsByStoreId($params);
if(count($agentsArr) > 0){
$agentIds = "";
foreach ($agentsArr as $key => $value){
$agentIds .= $value["id"] . ",";
}
$agentIds = rtrim($agentIds, ",");
$conditions["agent_id"] = array("in",$agentIds);
}
}
$result["house_num"] = $this->houseModel->getAddHouseNumByAgentId($conditions);
$result["user_num"] = $this->userModel->getAddUserNumByAgentId($conditions);
$result["follow_up_num"] = $this->followUpModel->getAddFollowUpNumByAgentId($conditions);
return $result;
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -95,4 +95,23 @@ class FollowUpLogModel extends Model
->select();
}
/**
* 获取经纪人新增带看数量
* @param $params
* @return int|string
*/
public function getAddFollowUpNumByAgentId($params){
$where_ = [];
if(isset($params["agent_id"])){
$where_["agent_id"] = $params["agent_id"];
}
if(isset($params["create_time"])){
$where_["create_time"] = $params["create_time"];
}
return $this->db_
->where($where_)
->count();
}
}
\ No newline at end of file
......@@ -416,7 +416,7 @@ class GHouses extends BaseModel
* @param $params
* @return array|false|\PDOStatement|string|\think\Model
*/
function getHouseDetailById($field,$params){
public function getHouseDetailById($field,$params){
return Db::table($this->table)
->field($field)
->alias("a")
......@@ -425,6 +425,24 @@ class GHouses extends BaseModel
->find($params["id"]);
}
/**
* 获取经纪人时间段中新添加的楼盘个数
* @param $params
* @return int|string
*/
public function getAddHouseNumByAgentId($params){
$where_ = [];
if(isset($params["agent_id"])){
$where_["upload_id"] = $params["agent_id"];
}
if(isset($params["create_time"])){
$where_["create_time"] = $params["create_time"];
}
return Db::table($this->table)
->where($where_)
->count();
}
/******zw end ************/
}
......@@ -283,4 +283,24 @@ class Users extends Model
->select();
return $data;
}*/
/**
* 获取经纪人新增用户数量
* @param $params
* @return int|string
*/
public function getAddUserNumByAgentId($params){
$where_ = [];
if(isset($params["agent_id"])){
$where_["agent_id"] = $params["agent_id"];
}
if(isset($params["create_time"])){
$where_["create_time"] = $params["create_time"];
}
return Db::table($this->table)
->where($where_)
->count();
}
}
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